Search in sources :

Example 11 with NetworkController

use of com.emc.storageos.networkcontroller.NetworkController in project coprhd-controller by CoprHD.

the class NetworkSystemService method doDiscoverNetworkSystem.

/**
 * Common code for submitting a request for discovery. The request may not be performed
 * by the discovery framework if a discovery was recently performed or is ongoing for
 * the network system.
 *
 * @param device the network system to be discovered to re-discovered.
 *            provided, a new taskId is generated.
 * @return the task used to track the discovery job
 */
private TaskResourceRep doDiscoverNetworkSystem(NetworkSystem device) {
    NetworkController controller = getNetworkController(device.getSystemType());
    DiscoveredObjectTaskScheduler scheduler = new DiscoveredObjectTaskScheduler(_dbClient, new NetworkJobExec(controller));
    String taskId = UUID.randomUUID().toString();
    ArrayList<AsyncTask> tasks = new ArrayList<AsyncTask>(1);
    tasks.add(new AsyncTask(NetworkSystem.class, device.getId(), taskId));
    TaskList taskList = scheduler.scheduleAsyncTasks(tasks);
    return taskList.getTaskList().iterator().next();
}
Also used : TaskList(com.emc.storageos.model.TaskList) AsyncTask(com.emc.storageos.volumecontroller.AsyncTask) ArrayList(java.util.ArrayList) NetworkSystem(com.emc.storageos.db.client.model.NetworkSystem) MapNetworkSystem(com.emc.storageos.api.mapper.functions.MapNetworkSystem) DiscoveredObjectTaskScheduler(com.emc.storageos.api.service.impl.resource.utils.DiscoveredObjectTaskScheduler) NetworkController(com.emc.storageos.networkcontroller.NetworkController)

Example 12 with NetworkController

use of com.emc.storageos.networkcontroller.NetworkController in project coprhd-controller by CoprHD.

the class NetworkSystemService method removeAliases.

/**
 * Removes one or more aliases from the specified network system. For Brocade the fabric from where
 * the aliases will be removed must be specified. For MDS, this input is ignored if provided.
 *
 * @param aliases A parameter structure listing the aliases to be removed. The alias member is an
 *            optional parameter and when provided, the alias membership is checked prior to removing it.
 * @param id the URN of a ViPR network system.
 * @prereq none
 * @brief Remove aliases to network system to VSAN or fabric
 * @return A task description structure.
 * @throws InternalException
 */
@POST
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/san-aliases/remove")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.RESTRICTED_SYSTEM_ADMIN })
public TaskResourceRep removeAliases(WwnAliasesDeleteParam aliases, @PathParam("id") URI id) throws InternalException {
    String task = UUID.randomUUID().toString();
    ArgValidator.checkFieldUriType(id, NetworkSystem.class, "id");
    ArgValidator.checkFieldNotEmpty(aliases.getAliases(), "aliases");
    NetworkSystem device = queryResource(id);
    String fabricId = aliases.getFabricId();
    if (Type.brocade.toString().equals(device.getSystemType())) {
        ArgValidator.checkFieldNotEmpty(fabricId, "fabric-id");
    }
    String fabricWwn = null;
    if (WWNUtility.isValidWWN(fabricId)) {
        fabricWwn = fabricId;
        fabricId = fabricId.replaceAll(":", "");
    }
    Operation op = _dbClient.createTaskOpStatus(NetworkSystem.class, device.getId(), task, ResourceOperationTypeEnum.REMOVE_ALIAS);
    List<ZoneWwnAlias> zoneAliases = new ArrayList<ZoneWwnAlias>();
    for (WwnAliasParam alias : aliases.getAliases()) {
        validateAlias(alias, false);
        zoneAliases.add(new ZoneWwnAlias(alias.getName(), alias.getAddress()));
        auditOp(OperationTypeEnum.REMOVE_ALIAS, true, AuditLogManager.AUDITOP_BEGIN, alias.getName(), device.getId().toString(), device.getLabel(), device.getPortNumber(), device.getUsername(), device.getSmisProviderIP(), device.getSmisPortNumber(), device.getSmisUserName(), device.getSmisUseSSL(), device.getVersion(), device.getUptime());
    }
    NetworkController controller = getNetworkController(device.getSystemType());
    controller.removeAliases(device.getId(), fabricId, fabricWwn, zoneAliases, task);
    return toTask(device, task, op);
}
Also used : WwnAliasParam(com.emc.storageos.model.network.WwnAliasParam) NetworkSystem(com.emc.storageos.db.client.model.NetworkSystem) MapNetworkSystem(com.emc.storageos.api.mapper.functions.MapNetworkSystem) ArrayList(java.util.ArrayList) Operation(com.emc.storageos.db.client.model.Operation) ZoneWwnAlias(com.emc.storageos.networkcontroller.impl.mds.ZoneWwnAlias) NetworkController(com.emc.storageos.networkcontroller.NetworkController) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Aggregations

NetworkController (com.emc.storageos.networkcontroller.NetworkController)12 MapNetworkSystem (com.emc.storageos.api.mapper.functions.MapNetworkSystem)11 NetworkSystem (com.emc.storageos.db.client.model.NetworkSystem)11 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)10 Path (javax.ws.rs.Path)10 Produces (javax.ws.rs.Produces)10 ArrayList (java.util.ArrayList)8 Operation (com.emc.storageos.db.client.model.Operation)7 Consumes (javax.ws.rs.Consumes)7 POST (javax.ws.rs.POST)5 ZoneMember (com.emc.storageos.networkcontroller.impl.mds.ZoneMember)4 SanZone (com.emc.storageos.model.network.SanZone)3 WwnAliasParam (com.emc.storageos.model.network.WwnAliasParam)3 Zone (com.emc.storageos.networkcontroller.impl.mds.Zone)3 GET (javax.ws.rs.GET)3 ZoneWwnAlias (com.emc.storageos.networkcontroller.impl.mds.ZoneWwnAlias)2 PUT (javax.ws.rs.PUT)2 DiscoveredObjectTaskScheduler (com.emc.storageos.api.service.impl.resource.utils.DiscoveredObjectTaskScheduler)1 TaskList (com.emc.storageos.model.TaskList)1 Fabrics (com.emc.storageos.model.network.Fabrics)1