def create_cloud_compute(config, context, dc): """ Creates the default cloud compute entities """ log.info("### Configuring the cloud ###") cloud = CloudCompute(context) # Create it into the 'abiquo' enterprise, to make it easier to use admin = context.getAdministrationService() enterprise = admin.findEnterprise(EnterprisePredicates.name("Abiquo")) vdc = cloud.create_virtual_datacenter(dc, enterprise, HypervisorType.valueOf(config.get("machine", "type")), config.get("virtual datacenter", "name"), config.get("private network", "name"), config.get("private network", "address"), config.getint("private network", "mask"), config.get("private network", "gateway")) vapp = cloud.create_virtual_appliance(vdc, config.get("virtual appliance", "name")) cloud.refresh_template_repository(enterprise, dc) template = find_smallest_template(context, vdc) if template: cloud.create_virtual_machine(vapp, template) return vdc
def create_infrastructure_compute(config, context): """ Creates the default infrastructure compute entities.. """ log.info("### Configuring infrastructure ###") comp = InfrastructureCompute(context) dc = comp.create_datacenter(config.get("datacenter", "name"), config.get("datacenter", "location")) rack = comp.create_rack(dc, config.get("rack", "name"), config.getint("rack", "vlan-min"), config.getint("rack", "vlan-max"), config.getint("rack", "nrsq")) sections = filter(lambda s: s.startswith("machine"), config.sections()) for section in sections: comp.create_machine(rack, HypervisorType.valueOf(config.get(section, "type")), config.get(section, "address"), config.get(section, "user"), config.get(section, "password"), config.get(section, "datastore"), config.get(section, "vswitch")) return dc
def create_cloud_compute(config, context, dc): """ Creates the default cloud compute entities """ log.info("### Configuring the cloud ###") cloud = CloudCompute(context) # Create it into the 'abiquo' enterprise, to make it easier to use admin = context.getAdministrationService() enterprise = admin.findEnterprise(EnterprisePredicates.name("Abiquo")) vdc = cloud.create_virtual_datacenter( dc, enterprise, HypervisorType.valueOf(config.get("machine", "type")), config.get("virtual datacenter", "name"), config.get("private network", "name"), config.get("private network", "address"), config.getint("private network", "mask"), config.get("private network", "gateway")) vapp = cloud.create_virtual_appliance( vdc, config.get("virtual appliance", "name")) cloud.refresh_template_repository(enterprise, dc) template = find_smallest_template(context, vdc) if template: cloud.create_virtual_machine(vapp, template) return vdc
def create_infrastructure_compute(config, context): """ Creates the default infrastructure compute entities. """ log.info("### Configuring infrastructure ###") comp = InfrastructureCompute(context) rs_address = config.get("datacenter", "rs") \ if config.has_option("datacenter", "rs") \ else context.getApiContext().getEndpoint().getHost() dc = comp.create_datacenter(config.get("datacenter", "name"), config.get("datacenter", "location"), rs_address) rack = comp.create_rack(dc, config.get("rack", "name"), config.getint("rack", "vlan-min"), config.getint("rack", "vlan-max"), config.getint("rack", "nrsq")) sections = filter(lambda s: s.startswith("machine"), config.sections()) for section in sections: comp.create_machine( rack, HypervisorType.valueOf(config.get(section, "type")), config.get(section, "address"), config.get(section, "user"), config.get(section, "password"), config.get(section, "datastore"), config.get(section, "vswitch")) return dc
return else: raise ex rack = Rack.builder(api_context, dc).name('rack').build() rack.save() log.debug("New datacenter 'kahuna' created.") else: rack = dc.findRack(RackPredicates.name('rack')) if not rack: rack = Rack.builder(api_context, dc).name('rack').build() rack.save() log.debug("Datacenter 'kahuna' found") # discover machine if hypervisor: hypTypes = [HypervisorType.valueOf(hypervisor)] else: hypTypes = HypervisorType.values() machine = None for hyp in hypTypes: try: log.debug("Trying hypervisor %s" % hyp.name()) machine = dc.discoverSingleMachine(host, hyp, user, psswd) break except (AbiquoException, HttpResponseException), ex: if ex.hasError("NC-3") or ex.hasError("RS-2"): print ex.getMessage().replace("\n", "") return log.debug(ex.getMessage().replace("\n", ""))
dc.delete() return else: raise ex rack = Rack.builder(context,dc).name('rack').build() rack.save() log.debug("New datacenter 'kahuna' created.") else: rack = dc.findRack(RackPredicates.name('rack')) if not rack: rack = Rack.builder(context,dc).name('rack').build() rack.save() log.debug("Datacenter 'kahuna' found") # discover machine hypTypes = [HypervisorType.valueOf(hypervisor)] if hypervisor else HypervisorType.values() machine = None for hyp in hypTypes: try: log.debug("Trying hypervisor %s" % hyp.name()) machine = dc.discoverSingleMachine(host, hyp, user, psswd) break except (AbiquoException, HttpResponseException), ex: if ex.hasError("NC-3") or ex.hasError("RS-2"): print ex.getMessage().replace("\n","") return log.debug(ex.getMessage().replace("\n","")) if not machine: print "Not machine found in %s" % host
return else: raise ex rack = Rack.builder(api_context, dc).name('rack').build() rack.save() log.debug("New datacenter 'kahuna' created.") else: rack = dc.findRack(RackPredicates.name('rack')) if not rack: rack = Rack.builder(api_context, dc).name('rack').build() rack.save() log.debug("Datacenter 'kahuna' found") # discover machine if hypervisor: hypTypes = [HypervisorType.valueOf(hypervisor)] else: hypTypes = HypervisorType.values() machine = None for hyp in hypTypes: try: log.debug("Trying hypervisor %s" % hyp.name()) machine = dc.discoverSingleMachine(host, hyp, user, psswd) break except (AbiquoException, HttpResponseException), ex: if ex.hasError("NC-3") or ex.hasError("RS-2"): print ex.getMessage().replace("\n", "") return log.debug(ex.getMessage().replace("\n", ""))