Tabnine Logo
ManagementService
Code IndexAdd Tabnine to your IDE (free)

How to use
ManagementService
in
com.cloud.server

Best Java code snippets using com.cloud.server.ManagementService (Showing top 20 results out of 315)

origin: apache/cloudstack

protected List<ClusterResponse> getClusterResponses() {
  Pair<List<? extends Cluster>, Integer> result = _mgr.searchForClusters(this);
  List<ClusterResponse> clusterResponses = new ArrayList<ClusterResponse>();
  for (Cluster cluster : result.first()) {
    ClusterResponse clusterResponse = _responseGenerator.createClusterResponse(cluster, showCapacities);
    clusterResponse.setObjectName("cluster");
    clusterResponses.add(clusterResponse);
  }
  return clusterResponses;
}
origin: apache/cloudstack

@Test
public void testCreateSuccess() {
  Configuration cfg = Mockito.mock(Configuration.class);
  listCfgsByCmd._mgr = mgr;
  listCfgsByCmd._responseGenerator = responseGenerator;
  List<Configuration> configList = new ArrayList<Configuration>();
  configList.add(cfg);
  Pair<List<? extends Configuration>, Integer> result = new Pair<List<? extends Configuration>, Integer>(configList, 1);
  try {
    Mockito.when(mgr.searchForConfigurations(listCfgsByCmd)).thenReturn(result);
  } catch (Exception e) {
    Assert.fail("Received exception when success expected " + e.getMessage());
  }
  ConfigurationResponse cfgResponse = new ConfigurationResponse();
  cfgResponse.setName("Test case");
  Mockito.when(responseGenerator.createConfigurationResponse(cfg)).thenReturn(cfgResponse);
  listCfgsByCmd.execute();
  Mockito.verify(responseGenerator).createConfigurationResponse(cfg);
  ListResponse<ConfigurationResponse> actualResponse = (ListResponse<ConfigurationResponse>)listCfgsByCmd.getResponseObject();
  Assert.assertEquals(cfgResponse, actualResponse.getResponses().get(0));
}
origin: apache/cloudstack

  @Override
  public void execute() {
    if (getClusterId() == null) {
      _mgr.updateHostPassword(this);
      _resourceService.updateHostPassword(this);
    } else {
      _mgr.updateClusterPassword(this);
      _resourceService.updateClusterPassword(this);
    }

    setResponseObject(new SuccessResponse(getCommandName()));
  }
}
origin: apache/cloudstack

public String getPassword() {
  if (Strings.isNullOrEmpty(password)) {
    password = _mgr.generateRandomPassword();
  }
  return password;
}
origin: apache/cloudstack

  @Test
  public void testCreateSuccess() {

    updateHostPasswordCmd._mgr = managementServer;
    updateHostPasswordCmd._resourceService = resourceService;
    updateHostPasswordCmd._responseGenerator = responseGenerator;

    try {
      Mockito.when(managementServer.updateHostPassword(updateHostPasswordCmd)).thenReturn(true);
    } catch (final Exception e) {
      fail("Received exception when success expected " + e.getMessage());
    }

    try {
      updateHostPasswordCmd.execute();
    } catch (final ServerApiException exception) {
      assertEquals("Failed to update config", exception.getDescription());
    }

    assertFalse("The attribute updatePasswdOnHost should be false, but it isn't.", updateHostPasswordCmd.getUpdatePasswdOnHost());
    verify(managementServer, times(1)).updateHostPassword(updateHostPasswordCmd);
  }
}
origin: apache/cloudstack

  @Override
  public void execute() {
    Pair<List<? extends Vlan>, Integer> vlans = _mgr.searchForVlans(this);
    ListResponse<VlanIpRangeResponse> response = new ListResponse<VlanIpRangeResponse>();
    List<VlanIpRangeResponse> vlanResponses = new ArrayList<VlanIpRangeResponse>();
    for (Vlan vlan : vlans.first()) {
      VlanIpRangeResponse vlanResponse = _responseGenerator.createVlanIpRangeResponse(vlan);
      vlanResponse.setObjectName("vlaniprange");
      vlanResponses.add(vlanResponse);
    }

    response.setResponses(vlanResponses, vlans.second());
    response.setResponseName(getCommandName());
    setResponseObject(response);
  }
}
origin: apache/cloudstack

  @Override
  public void execute() {
    List<String> planners = _mgr.listDeploymentPlanners();
    ListResponse<DeploymentPlannersResponse> response = new ListResponse<DeploymentPlannersResponse>();
    List<DeploymentPlannersResponse> plannerResponses = new ArrayList<DeploymentPlannersResponse>();

    for (String planner : planners) {
      DeploymentPlannersResponse plannerResponse = new DeploymentPlannersResponse();
      plannerResponse.setName(planner);
      plannerResponse.setObjectName("deploymentPlanner");
      plannerResponses.add(plannerResponse);
    }

    response.setResponses(plannerResponses);
    response.setResponseName(getCommandName());
    this.setResponseObject(response);

  }
}
origin: apache/cloudstack

@Override
public void create() {
  GuestOSHypervisor guestOsMapping = _mgr.addGuestOsMapping(this);
  if (guestOsMapping != null) {
    setEntityId(guestOsMapping.getId());
    setEntityUuid(guestOsMapping.getUuid());
  } else {
    throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add guest OS mapping entity");
  }
}
origin: apache/cloudstack

@Override
public void create() {
  GuestOS guestOs = _mgr.addGuestOs(this);
  if (guestOs != null) {
    setEntityId(guestOs.getId());
    setEntityUuid(guestOs.getUuid());
  } else {
    throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add new guest OS type entity");
  }
}
origin: apache/cloudstack

  @Override
  public void execute() {
    if (ids == null && type == null && endDate == null) {
      throw new InvalidParameterValueException("either ids, type or enddate must be specified");
    } else if (startDate != null && endDate == null) {
      throw new InvalidParameterValueException("enddate must be specified with startdate parameter");
    }
    boolean result = _mgr.archiveEvents(this);
    if (result) {
      SuccessResponse response = new SuccessResponse(getCommandName());
      setResponseObject(response);
    } else {
      throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Unable to archive Events, one or more parameters has invalid values");
    }
  }
}
origin: apache/cloudstack

  @Override
  public void execute() {
    if (ids == null && type == null && endDate == null) {
      throw new InvalidParameterValueException("either ids, type, startdate or enddate must be specified");
    } else if (startDate != null && endDate == null) {
      throw new InvalidParameterValueException("enddate must be specified with startdate parameter");
    }
    boolean result = _mgr.archiveAlerts(this);
    if (result) {
      SuccessResponse response = new SuccessResponse(getCommandName());
      this.setResponseObject(response);
    } else {
      throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Unable to archive Alerts, one or more parameters has invalid values");
    }
  }
}
origin: apache/cloudstack

@DB
protected void updateSystemvmPassword() {
  String userid = System.getProperty("user.name");
  if (!userid.startsWith("cloud")) {
    return;
  }
  if (!Boolean.valueOf(_configDao.getValue("system.vm.random.password"))) {
    return;
  }
  String already = _configDao.getValue("system.vm.password");
  if (already == null) {
    TransactionLegacy txn = TransactionLegacy.currentTxn();
    try {
      String rpassword = _mgrService.generateRandomPassword();
      String wSql = "INSERT INTO `cloud`.`configuration` (category, instance, component, name, value, description) "
      + "VALUES ('Secure','DEFAULT', 'management-server','system.vm.password', ?,'randmon password generated each management server starts for system vm')";
      PreparedStatement stmt = txn.prepareAutoCloseStatement(wSql);
      stmt.setString(1, DBEncryptionUtil.encrypt(rpassword));
      stmt.executeUpdate();
      s_logger.info("Updated systemvm password in database");
    } catch (SQLException e) {
      s_logger.error("Cannot retrieve systemvm password", e);
    }
  }
}
origin: apache/cloudstack

@Test
public void testExecuteForNullResult() {
  updateHostPasswordCmd._mgr = managementServer;
  updateHostPasswordCmd._resourceService = resourceService;
  try {
    Mockito.when(managementServer.updateHostPassword(updateHostPasswordCmd)).thenReturn(false);
  } catch (final InvalidParameterValueException e) {
    fail(e.getMessage());
  } catch (final IllegalArgumentException e) {
    fail(e.getMessage());
  }
  try {
    updateHostPasswordCmd.execute();
  } catch (final ServerApiException exception) {
    Assert.assertEquals("Failed to update config", exception.getDescription());
  }
  assertFalse("The attribute updatePasswdOnHost should be false, but it isn't.", updateHostPasswordCmd.getUpdatePasswdOnHost());
  verify(managementServer, times(1)).updateHostPassword(updateHostPasswordCmd);
}
origin: apache/cloudstack

@Override
public void execute() {
  Pair<List<? extends Vlan>, Integer> vlans = _mgr.searchForVlans(this);
  ListResponse<NuageVlanIpRangeResponse> response = new ListResponse<NuageVlanIpRangeResponse>();
  List<NuageVlanIpRangeResponse> vlanIpRanges = _nuageVspManager.filterNuageVlanIpRanges(vlans.first(), underlay);
  response.setResponses(vlanIpRanges);
  response.setResponseName(getCommandName());
  this.setResponseObject(response);
}
origin: apache/cloudstack

final List<String> planners = _mgr.listDeploymentPlanners();
if (planners != null && !planners.isEmpty()) {
  if (!planners.contains(cmd.getDeploymentPlanner())) {
origin: MissionCriticalCloud/cosmic

@Override
public void create() {
  final GuestOSHypervisor guestOsMapping = _mgr.addGuestOsMapping(this);
  if (guestOsMapping != null) {
    setEntityId(guestOsMapping.getId());
    setEntityUuid(guestOsMapping.getUuid());
  } else {
    throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add guest OS mapping entity");
  }
}
origin: MissionCriticalCloud/cosmic

@Override
public void create() {
  final GuestOS guestOs = _mgr.addGuestOs(this);
  if (guestOs != null) {
    setEntityId(guestOs.getId());
    setEntityUuid(guestOs.getUuid());
  } else {
    throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add new guest OS type entity");
  }
}
origin: MissionCriticalCloud/cosmic

@Override
public void execute() {
  if (ids == null && type == null && endDate == null) {
    throw new InvalidParameterValueException("either ids, type or enddate must be specified");
  } else if (startDate != null && endDate == null) {
    throw new InvalidParameterValueException("enddate must be specified with startdate parameter");
  }
  final boolean result = _mgr.archiveEvents(this);
  if (result) {
    final SuccessResponse response = new SuccessResponse(getCommandName());
    setResponseObject(response);
  } else {
    throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Unable to archive Events, one or more parameters has invalid values");
  }
}
origin: MissionCriticalCloud/cosmic

@Override
public void execute() {
  if (ids == null && type == null && endDate == null) {
    throw new InvalidParameterValueException("either ids, type, startdate or enddate must be specified");
  } else if (startDate != null && endDate == null) {
    throw new InvalidParameterValueException("enddate must be specified with startdate parameter");
  }
  final boolean result = _mgr.archiveAlerts(this);
  if (result) {
    final SuccessResponse response = new SuccessResponse(getCommandName());
    this.setResponseObject(response);
  } else {
    throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Unable to archive Alerts, one or more parameters has invalid values");
  }
}
origin: apache/cloudstack

  @Override
  public void execute() throws ResourceUnavailableException, InsufficientCapacityException{
    password = _mgr.generateRandomPassword();
    CallContext.current().setEventDetails("Vm Id: "+getId());
    UserVm result = _userVmService.resetVMPassword(this, password);
    if (result != null){
      UserVmResponse response = _responseGenerator.createUserVmResponse(ResponseView.Full, "virtualmachine", result).get(0);
      response.setResponseName(getCommandName());
      setResponseObject(response);
    } else {
      throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to reset vm password");
    }
  }
}
com.cloud.serverManagementService

Javadoc

Hopefully this is temporary.

Most used methods

  • searchForClusters
    Searches for Clusters by the specified search criteria
  • searchForConfigurations
    returns the a map of the names/values in the configuraton table
  • updateHostPassword
  • generateRandomPassword
    Generates a random password that will be used (initially) by newly created and started virtual machi
  • listDeploymentPlanners
  • searchForVlans
    Searches for vlan by the specified search criteria Can search by: "id", "vlan", "name", "zoneID"
  • addGuestOs
    Adds a new guest OS
  • addGuestOsMapping
    Adds a new guest OS mapping
  • archiveAlerts
    Archive alerts
  • archiveEvents
    Archive events
  • cleanupVMReservations
  • createSSHKeyPair
    Creates a new
  • cleanupVMReservations,
  • createSSHKeyPair,
  • deleteAlerts,
  • deleteEvents,
  • deleteSSHKeyPair,
  • destroySystemVM,
  • findSystemVMTypeById,
  • getAddedGuestOs,
  • getAddedGuestOsMapping,
  • getCloudIdentifierResponse

Popular in Java

  • Reactive rest calls using spring rest template
  • getSystemService (Context)
  • onRequestPermissionsResult (Fragment)
  • putExtra (Intent)
  • Component (java.awt)
    A component is an object having a graphical representation that can be displayed on the screen and t
  • InputStream (java.io)
    A readable source of bytes.Most clients will use input streams that read data from the file system (
  • URI (java.net)
    A Uniform Resource Identifier that identifies an abstract or physical resource, as specified by RFC
  • Selector (java.nio.channels)
    A controller for the selection of SelectableChannel objects. Selectable channels can be registered w
  • JFrame (javax.swing)
  • Reflections (org.reflections)
    Reflections one-stop-shop objectReflections scans your classpath, indexes the metadata, allows you t
  • Best IntelliJ plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now