You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by gi...@apache.org on 2014/02/04 07:32:25 UTC
[1/6] CLOUDSTACK-6006: Remove integration folder and lib
Updated Branches:
refs/heads/marvin a908b8d94 -> bf72441d1
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/tools/marvin/marvin/lib/common.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/lib/common.py b/tools/marvin/marvin/lib/common.py
new file mode 100644
index 0000000..41416d4
--- /dev/null
+++ b/tools/marvin/marvin/lib/common.py
@@ -0,0 +1,955 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+"""Common functions
+"""
+
+#Import Local Modules
+from marvin.cloudstackAPI import (listConfigurations,
+ listPhysicalNetworks,
+ listRegions,
+ addNetworkServiceProvider,
+ updateNetworkServiceProvider,
+ listDomains,
+ listZones,
+ listPods,
+ listOsTypes,
+ listTemplates,
+ updateResourceLimit,
+ listRouters,
+ listNetworks,
+ listClusters,
+ listSystemVms,
+ listStoragePools,
+ listVirtualMachines,
+ listLoadBalancerRuleInstances,
+ listFirewallRules,
+ listVolumes,
+ listIsos,
+ listAccounts,
+ listSnapshotPolicies,
+ listDiskOfferings,
+ listVlanIpRanges,
+ listUsageRecords,
+ listNetworkServiceProviders,
+ listHosts,
+ listPublicIpAddresses,
+ listPortForwardingRules,
+ listLoadBalancerRules,
+ listSnapshots,
+ listUsers,
+ listEvents,
+ listServiceOfferings,
+ listVirtualRouterElements,
+ listNetworkOfferings,
+ listResourceLimits,
+ listVPCOfferings)
+from marvin.lib.base import (Configurations,
+ NetScaler,
+ Template,
+ Resources,
+ PhysicalNetwork,
+ Host)
+from marvin.lib.utils import (get_process_status,
+ xsplit)
+
+from marvin.sshClient import SshClient
+import random
+from utils import *
+from base import *
+from marvin.codes import PASS
+from marvin.lib.utils import validateList
+
+#Import System modules
+import time
+
+
+def is_config_suitable(apiclient, name, value):
+ """
+ Ensure if the deployment has the expected `value` for the global setting `name'
+ @return: true if value is set, else false
+ """
+ configs = Configurations.list(apiclient, name=name)
+ assert(configs is not None and isinstance(configs, list) and len(configs) > 0)
+ return configs[0].value == value
+
+def wait_for_cleanup(apiclient, configs=None):
+ """Sleeps till the cleanup configs passed"""
+
+ # Configs list consists of the list of global configs
+ if not isinstance(configs, list):
+ return
+ for config in configs:
+ cmd = listConfigurations.listConfigurationsCmd()
+ cmd.name = config
+ cmd.listall = True
+ try:
+ config_descs = apiclient.listConfigurations(cmd)
+ except Exception as e:
+ raise Exception("Failed to fetch configurations: %s" % e)
+
+ if not isinstance(config_descs, list):
+ raise Exception("List configs didn't returned a valid data")
+
+ config_desc = config_descs[0]
+ # Sleep for the config_desc.value time
+ time.sleep(int(config_desc.value))
+ return
+
+def add_netscaler(apiclient, zoneid, NSservice):
+ """ Adds Netscaler device and enables NS provider"""
+
+ cmd = listPhysicalNetworks.listPhysicalNetworksCmd()
+ cmd.zoneid = zoneid
+ physical_networks = apiclient.listPhysicalNetworks(cmd)
+ if isinstance(physical_networks, list):
+ physical_network = physical_networks[0]
+
+ cmd = listNetworkServiceProviders.listNetworkServiceProvidersCmd()
+ cmd.name = 'Netscaler'
+ cmd.physicalnetworkid=physical_network.id
+ nw_service_providers = apiclient.listNetworkServiceProviders(cmd)
+
+ if isinstance(nw_service_providers, list):
+ netscaler_provider = nw_service_providers[0]
+ else:
+ cmd1 = addNetworkServiceProvider.addNetworkServiceProviderCmd()
+ cmd1.name = 'Netscaler'
+ cmd1.physicalnetworkid = physical_network.id
+ netscaler_provider = apiclient.addNetworkServiceProvider(cmd1)
+
+ netscaler = NetScaler.add(
+ apiclient,
+ NSservice,
+ physicalnetworkid=physical_network.id
+ )
+ if netscaler_provider.state != 'Enabled':
+ cmd = updateNetworkServiceProvider.updateNetworkServiceProviderCmd()
+ cmd.id = netscaler_provider.id
+ cmd.state = 'Enabled'
+ apiclient.updateNetworkServiceProvider(cmd)
+
+ return netscaler
+
+def get_region(apiclient, region_id=None, region_name=None):
+ '''
+ @name : get_region
+ @Desc : Returns the Region Information for a given region id or region name
+ @Input : region_name: Name of the Region
+ region_id : Id of the region
+ @Output : 1. Region Information for the passed inputs else first Region
+ 2. FAILED In case the cmd failed
+ '''
+ if region_id is None and region_name is None:
+ return FAILED
+ cmd = listRegions.listRegionsCmd()
+ if region_name is not None:
+ cmd.name = region_name
+ if region_id is not None:
+ cmd.id = region_id
+ cmd_out = apiclient.listRegions(cmd)
+ return FAILED if validateList(cmd_out)[0] != PASS else cmd_out
+
+
+def get_domain(apiclient, domain_id=None, domain_name=None):
+ '''
+ @name : get_domain
+ @Desc : Returns the Domain Information for a given domain id or domain name
+ @Input : domain id : Id of the Domain
+ domain_name : Name of the Domain
+ @Output : 1. Domain Information for the passed inputs else first Domain
+ 2. FAILED In case the cmd failed
+ '''
+ cmd = listDomains.listDomainsCmd()
+
+ if domain_name is not None:
+ cmd.name = domain_name
+ if domain_id is not None:
+ cmd.id = domain_id
+ cmd_out = apiclient.listRegions(cmd)
+ return FAILED if validateList(cmd_out)[0] != PASS else cmd_out
+
+
+def get_zone(apiclient, zone_name=None, zone_id=None):
+ '''
+ @name : get_zone
+ @Desc :Returns the Zone Information for a given zone id or Zone Name
+ @Input : zone_name: Name of the Zone
+ zone_id : Id of the zone
+ @Output : 1. Zone Information for the passed inputs else first zone
+ 2. FAILED In case the cmd failed
+ '''
+ cmd = listZones.listZonesCmd()
+ if zone_name is not None:
+ cmd.name = zone_name
+ if zone_id is not None:
+ cmd.id = zone_id
+
+ cmd_out = apiclient.listZones(cmd)
+
+ if validateList(cmd_out)[0] != PASS: return FAILED
+ '''
+ Check if input zone name and zone id is None,
+ then return first element of List Zones command
+ '''
+ if (zone_name is None and zone_id is None):
+ return cmd_out[0]
+ else:
+ return cmd_out
+
+
+
+def get_pod(apiclient, zone_id=None, pod_id=None, pod_name=None):
+ '''
+ @name : get_pod
+ @Desc : Returns the Pod Information for a given zone id or Zone Name
+ @Input : zone_id: Id of the Zone
+ pod_name : Name of the Pod
+ pod_id : Id of the Pod
+ @Output : 1. Pod Information for the pod
+ 2. FAILED In case the cmd failed
+ '''
+ cmd = listPods.listPodsCmd()
+
+ if pod_name is not None:
+ cmd.name = pod_name
+ if pod_id is not None:
+ cmd.id = pod_id
+ if zone_id is not None:
+ cmd.zoneid = zone_id
+
+ cmd_out = apiclient.listPods(cmd)
+
+ return FAILED if (validateList(cmd_out)[0] != PASS) else cmd_out
+
+
+def get_template(apiclient, zone_id=None, ostype_desc=None, template_filter="featured", template_type='BUILTIN',
+ template_id=None, template_name=None, account=None, domain_id=None, project_id=None,
+ hypervisor=None):
+ '''
+ @Name : get_template
+ @Desc : Retrieves the template Information based upon inputs provided
+ Template is retrieved based upon either of the inputs matched
+ condition
+ @Input : returns a template"
+ @Output : FAILED in case of any failure
+ template Information matching the inputs
+ '''
+
+ '''
+ Get OS TypeID First based upon ostype_desc
+ '''
+ cmd = listOsTypes.listOsTypesCmd()
+ cmd.description = ostype_desc
+ ostypes_out = apiclient.listOsTypes(cmd)
+
+ if (validateList(ostypes_out)[0] != PASS): return FAILED
+
+ ostype_id = ostypes_out[0].id
+
+ listcmd = listTemplates.listTemplatesCmd()
+ cmd.templatefilter = template_filter
+ if domain_id is not None:
+ cmd.domainid = domain_id
+ if zone_id is not None:
+ cmd.zoneid = zone_id
+ if template_id is not None:
+ cmd.id = template_id
+ if template_name is not None:
+ cmd.name = template_name
+ if hypervisor is not None:
+ cmd.hypervisor = hypervisor
+ if project_id is not None:
+ cmd.projectid = project_id
+ if account is not None:
+ cmd.account = account
+
+ '''
+ Get the Templates pertaining
+ '''
+ list_templatesout = apiclient.listTemplates(cmd)
+ if validateList(list_templatesout)[0] != PASS: return FAILED
+
+ for template in list_templatesout:
+ if template.ostypeid == ostype_id and template.isready and template.templatetype == template_type:
+ return template
+ '''
+ Return Failed if None of the templates matched
+ '''
+ return FAILED
+
+def download_systemplates_sec_storage(server, services):
+ """Download System templates on sec storage"""
+
+ try:
+ # Login to management server
+ ssh = SshClient(
+ server["ipaddress"],
+ server["port"],
+ server["username"],
+ server["password"]
+ )
+ except Exception:
+ raise Exception("SSH access failed for server with IP address: %s" %
+ server["ipaddess"])
+ # Mount Secondary Storage on Management Server
+ cmds = [
+ "mkdir -p %s" % services["mnt_dir"],
+ "mount -t nfs %s:/%s %s" % (
+ services["sec_storage"],
+ services["path"],
+ services["mnt_dir"]
+ ),
+ "%s -m %s -u %s -h %s -F" % (
+ services["command"],
+ services["mnt_dir"],
+ services["download_url"],
+ services["hypervisor"]
+ )
+ ]
+ for c in cmds:
+ result = ssh.execute(c)
+
+ res = str(result)
+
+ # Unmount the Secondary storage
+ ssh.execute("umount %s" % (services["mnt_dir"]))
+
+ if res.count("Successfully installed system VM template") == 1:
+ return
+ else:
+ raise Exception("Failed to download System Templates on Sec Storage")
+ return
+
+
+def wait_for_ssvms(apiclient, zoneid, podid, interval=60):
+ """After setup wait for SSVMs to come Up"""
+
+ time.sleep(interval)
+ timeout = 40
+ while True:
+ list_ssvm_response = list_ssvms(
+ apiclient,
+ systemvmtype='secondarystoragevm',
+ zoneid=zoneid,
+ podid=podid
+ )
+ ssvm = list_ssvm_response[0]
+ if ssvm.state != 'Running':
+ # Sleep to ensure SSVMs are Up and Running
+ time.sleep(interval)
+ timeout = timeout - 1
+ elif ssvm.state == 'Running':
+ break
+ elif timeout == 0:
+ raise Exception("SSVM failed to come up")
+ break
+
+ timeout = 40
+ while True:
+ list_ssvm_response = list_ssvms(
+ apiclient,
+ systemvmtype='consoleproxy',
+ zoneid=zoneid,
+ podid=podid
+ )
+ cpvm = list_ssvm_response[0]
+ if cpvm.state != 'Running':
+ # Sleep to ensure SSVMs are Up and Running
+ time.sleep(interval)
+ timeout = timeout - 1
+ elif cpvm.state == 'Running':
+ break
+ elif timeout == 0:
+ raise Exception("CPVM failed to come up")
+ break
+ return
+
+def get_builtin_template_info(apiclient, zoneid):
+ """Returns hypervisor specific infor for templates"""
+
+ list_template_response = Template.list(
+ apiclient,
+ templatefilter='featured',
+ zoneid=zoneid,
+ )
+
+ for b_template in list_template_response:
+ if b_template.templatetype == 'BUILTIN':
+ break
+
+ extract_response = Template.extract(apiclient,
+ b_template.id,
+ 'HTTP_DOWNLOAD',
+ zoneid)
+
+ return extract_response.url, b_template.hypervisor, b_template.format
+
+def download_builtin_templates(apiclient, zoneid, hypervisor, host,
+ linklocalip, interval=60):
+ """After setup wait till builtin templates are downloaded"""
+
+ # Change IPTABLES Rules
+ get_process_status(
+ host["ipaddress"],
+ host["port"],
+ host["username"],
+ host["password"],
+ linklocalip,
+ "iptables -P INPUT ACCEPT"
+ )
+ time.sleep(interval)
+ # Find the BUILTIN Templates for given Zone, Hypervisor
+ list_template_response = list_templates(
+ apiclient,
+ hypervisor=hypervisor,
+ zoneid=zoneid,
+ templatefilter='self'
+ )
+
+ if not isinstance(list_template_response, list):
+ raise Exception("Failed to download BUILTIN templates")
+
+ # Ensure all BUILTIN templates are downloaded
+ templateid = None
+ for template in list_template_response:
+ if template.templatetype == "BUILTIN":
+ templateid = template.id
+
+ # Sleep to ensure that template is in downloading state after adding
+ # Sec storage
+ time.sleep(interval)
+ while True:
+ template_response = list_templates(
+ apiclient,
+ id=templateid,
+ zoneid=zoneid,
+ templatefilter='self'
+ )
+ template = template_response[0]
+ # If template is ready,
+ # template.status = Download Complete
+ # Downloading - x% Downloaded
+ # Error - Any other string
+ if template.status == 'Download Complete':
+ break
+
+ elif 'Downloaded' in template.status:
+ time.sleep(interval)
+
+ elif 'Installing' not in template.status:
+ raise Exception("ErrorInDownload")
+
+ return
+
+
+def update_resource_limit(apiclient, resourcetype, account=None,
+ domainid=None, max=None, projectid=None):
+ """Updates the resource limit to 'max' for given account"""
+
+ cmd = updateResourceLimit.updateResourceLimitCmd()
+ cmd.resourcetype = resourcetype
+ if account:
+ cmd.account = account
+ if domainid:
+ cmd.domainid = domainid
+ if max:
+ cmd.max = max
+ if projectid:
+ cmd.projectid = projectid
+ apiclient.updateResourceLimit(cmd)
+ return
+
+
+def list_os_types(apiclient, **kwargs):
+ """List all os types matching criteria"""
+
+ cmd = listOsTypes.listOsTypesCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listOsTypes(cmd))
+
+
+def list_routers(apiclient, **kwargs):
+ """List all Routers matching criteria"""
+
+ cmd = listRouters.listRoutersCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listRouters(cmd))
+
+
+def list_zones(apiclient, **kwargs):
+ """List all Zones matching criteria"""
+
+ cmd = listZones.listZonesCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listZones(cmd))
+
+
+def list_networks(apiclient, **kwargs):
+ """List all Networks matching criteria"""
+
+ cmd = listNetworks.listNetworksCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listNetworks(cmd))
+
+
+def list_clusters(apiclient, **kwargs):
+ """List all Clusters matching criteria"""
+
+ cmd = listClusters.listClustersCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listClusters(cmd))
+
+
+def list_ssvms(apiclient, **kwargs):
+ """List all SSVMs matching criteria"""
+
+ cmd = listSystemVms.listSystemVmsCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listSystemVms(cmd))
+
+
+def list_storage_pools(apiclient, **kwargs):
+ """List all storage pools matching criteria"""
+
+ cmd = listStoragePools.listStoragePoolsCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listStoragePools(cmd))
+
+
+def list_virtual_machines(apiclient, **kwargs):
+ """List all VMs matching criteria"""
+
+ cmd = listVirtualMachines.listVirtualMachinesCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listVirtualMachines(cmd))
+
+
+def list_hosts(apiclient, **kwargs):
+ """List all Hosts matching criteria"""
+
+ cmd = listHosts.listHostsCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listHosts(cmd))
+
+
+def list_configurations(apiclient, **kwargs):
+ """List configuration with specified name"""
+
+ cmd = listConfigurations.listConfigurationsCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listConfigurations(cmd))
+
+
+def list_publicIP(apiclient, **kwargs):
+ """List all Public IPs matching criteria"""
+
+ cmd = listPublicIpAddresses.listPublicIpAddressesCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listPublicIpAddresses(cmd))
+
+
+def list_nat_rules(apiclient, **kwargs):
+ """List all NAT rules matching criteria"""
+
+ cmd = listPortForwardingRules.listPortForwardingRulesCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listPortForwardingRules(cmd))
+
+
+def list_lb_rules(apiclient, **kwargs):
+ """List all Load balancing rules matching criteria"""
+
+ cmd = listLoadBalancerRules.listLoadBalancerRulesCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listLoadBalancerRules(cmd))
+
+
+def list_lb_instances(apiclient, **kwargs):
+ """List all Load balancing instances matching criteria"""
+
+ cmd = listLoadBalancerRuleInstances.listLoadBalancerRuleInstancesCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listLoadBalancerRuleInstances(cmd))
+
+
+def list_firewall_rules(apiclient, **kwargs):
+ """List all Firewall Rules matching criteria"""
+
+ cmd = listFirewallRules.listFirewallRulesCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listFirewallRules(cmd))
+
+
+def list_volumes(apiclient, **kwargs):
+ """List all volumes matching criteria"""
+
+ cmd = listVolumes.listVolumesCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listVolumes(cmd))
+
+
+def list_isos(apiclient, **kwargs):
+ """Lists all available ISO files."""
+
+ cmd = listIsos.listIsosCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listIsos(cmd))
+
+
+def list_snapshots(apiclient, **kwargs):
+ """List all snapshots matching criteria"""
+
+ cmd = listSnapshots.listSnapshotsCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listSnapshots(cmd))
+
+
+def list_templates(apiclient, **kwargs):
+ """List all templates matching criteria"""
+
+ cmd = listTemplates.listTemplatesCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listTemplates(cmd))
+
+
+def list_domains(apiclient, **kwargs):
+ """Lists domains"""
+
+ cmd = listDomains.listDomainsCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listDomains(cmd))
+
+
+def list_accounts(apiclient, **kwargs):
+ """Lists accounts and provides detailed account information for
+ listed accounts"""
+
+ cmd = listAccounts.listAccountsCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listAccounts(cmd))
+
+
+def list_users(apiclient, **kwargs):
+ """Lists users and provides detailed account information for
+ listed users"""
+
+ cmd = listUsers.listUsersCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listUsers(cmd))
+
+
+def list_snapshot_policy(apiclient, **kwargs):
+ """Lists snapshot policies."""
+
+ cmd = listSnapshotPolicies.listSnapshotPoliciesCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listSnapshotPolicies(cmd))
+
+
+def list_events(apiclient, **kwargs):
+ """Lists events"""
+
+ cmd = listEvents.listEventsCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listEvents(cmd))
+
+
+def list_disk_offering(apiclient, **kwargs):
+ """Lists all available disk offerings."""
+
+ cmd = listDiskOfferings.listDiskOfferingsCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listDiskOfferings(cmd))
+
+
+def list_service_offering(apiclient, **kwargs):
+ """Lists all available service offerings."""
+
+ cmd = listServiceOfferings.listServiceOfferingsCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listServiceOfferings(cmd))
+
+
+def list_vlan_ipranges(apiclient, **kwargs):
+ """Lists all VLAN IP ranges."""
+
+ cmd = listVlanIpRanges.listVlanIpRangesCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listVlanIpRanges(cmd))
+
+
+def list_usage_records(apiclient, **kwargs):
+ """Lists usage records for accounts"""
+
+ cmd = listUsageRecords.listUsageRecordsCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listUsageRecords(cmd))
+
+
+def list_nw_service_prividers(apiclient, **kwargs):
+ """Lists Network service providers"""
+
+ cmd = listNetworkServiceProviders.listNetworkServiceProvidersCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listNetworkServiceProviders(cmd))
+
+
+def list_virtual_router_elements(apiclient, **kwargs):
+ """Lists Virtual Router elements"""
+
+ cmd = listVirtualRouterElements.listVirtualRouterElementsCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listVirtualRouterElements(cmd))
+
+
+def list_network_offerings(apiclient, **kwargs):
+ """Lists network offerings"""
+
+ cmd = listNetworkOfferings.listNetworkOfferingsCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listNetworkOfferings(cmd))
+
+
+def list_resource_limits(apiclient, **kwargs):
+ """Lists resource limits"""
+
+ cmd = listResourceLimits.listResourceLimitsCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listResourceLimits(cmd))
+
+def list_vpc_offerings(apiclient, **kwargs):
+ """ Lists VPC offerings """
+
+ cmd = listVPCOfferings.listVPCOfferingsCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listVPCOfferings(cmd))
+
+def update_resource_count(apiclient, domainid, accountid=None,
+ projectid=None, rtype=None):
+ """updates the resource count
+ 0 - VM
+ 1 - Public IP
+ 2 - Volume
+ 3 - Snapshot
+ 4 - Template
+ 5 - Projects
+ 6 - Network
+ 7 - VPC
+ 8 - CPUs
+ 9 - RAM
+ 10 - Primary (shared) storage (Volumes)
+ 11 - Secondary storage (Snapshots, Templates & ISOs)
+ """
+
+ Resources.updateCount(apiclient,
+ domainid=domainid,
+ account=accountid if accountid else None,
+ projectid=projectid if projectid else None,
+ resourcetype=rtype if rtype else None
+ )
+ return
+
+def find_suitable_host(apiclient, vm):
+ """Returns a suitable host for VM migration"""
+
+ hosts = Host.list(apiclient,
+ virtualmachineid=vm.id,
+ listall=True)
+
+ if isinstance(hosts, list):
+ assert len(hosts) > 0, "List host should return valid response"
+ else:
+ raise Exception("Exception: List host should return valid response")
+ return hosts[0]
+
+def get_resource_type(resource_id):
+ """Returns resource type"""
+
+ lookup = { 0: "VM",
+ 1: "Public IP",
+ 2: "Volume",
+ 3: "Snapshot",
+ 4: "Template",
+ 5: "Projects",
+ 6: "Network",
+ 7: "VPC",
+ 8: "CPUs",
+ 9: "RAM",
+ 10: "Primary (shared) storage (Volumes)",
+ 11: "Secondary storage (Snapshots, Templates & ISOs)"
+ }
+
+ return lookup[resource_id]
+
+def get_portable_ip_range_services(config):
+ """ Reads config values related to portable ip and fills up
+ services accordingly"""
+
+ services = {}
+ attributeError = False
+
+ if config.portableIpRange.startip:
+ services["startip"] = config.portableIpRange.startip
+ else:
+ attributeError = True
+
+ if config.portableIpRange.endip:
+ services["endip"] = config.portableIpRange.endip
+ else:
+ attributeError = True
+
+ if config.portableIpRange.netmask:
+ services["netmask"] = config.portableIpRange.netmask
+ else:
+ attributeError = True
+
+ if config.portableIpRange.gateway:
+ services["gateway"] = config.portableIpRange.gateway
+ else:
+ attributeError = True
+
+ if config.portableIpRange.vlan:
+ services["vlan"] = config.portableIpRange.vlan
+
+ if attributeError:
+ services = None
+
+ return services
+
+def get_free_vlan(apiclient, zoneid):
+ """
+ Find an unallocated VLAN outside the range allocated to the physical network.
+
+ @note: This does not guarantee that the VLAN is available for use in
+ the deployment's network gear
+ @return: physical_network, shared_vlan_tag
+ """
+ list_physical_networks_response = PhysicalNetwork.list(
+ apiclient,
+ zoneid=zoneid
+ )
+ assert isinstance(list_physical_networks_response, list)
+ assert len(list_physical_networks_response) > 0, "No physical networks found in zone %s" % zoneid
+
+ physical_network = list_physical_networks_response[0]
+
+ networks = list_networks(apiclient, zoneid= zoneid, type='Shared')
+ usedVlanIds = []
+
+ if isinstance(networks, list) and len(networks) > 0:
+ usedVlanIds = [int(nw.vlan) for nw in networks if nw.vlan!="untagged"]
+
+ if hasattr(physical_network, "vlan") is False:
+ while True:
+ shared_ntwk_vlan = random.randrange(1,4095)
+ if shared_ntwk_vlan in usedVlanIds:
+ continue
+ else:
+ break
+ else:
+ vlans = xsplit(physical_network.vlan, ['-', ','])
+
+ assert len(vlans) > 0
+ assert int(vlans[0]) < int(vlans[-1]), "VLAN range %s was improperly split" % physical_network.vlan
+
+ retriesCount = 20 #Assuming random function will give different integer each time
+
+ shared_ntwk_vlan = None
+
+ while True:
+
+ if retriesCount == 0:
+ break
+
+ free_vlan = int(vlans[-1]) + random.randrange(1, 20)
+
+ if free_vlan > 4095:
+ free_vlan = int(vlans[0]) - random.randrange(1, 20)
+ if free_vlan < 0 or (free_vlan in usedVlanIds):
+ retriesCount -= 1
+ continue
+ else:
+ shared_ntwk_vlan = free_vlan
+ break
+
+ return physical_network, shared_ntwk_vlan
+
+def setNonContiguousVlanIds(apiclient, zoneid):
+ """
+ Form the non contiguous ranges based on currently assigned range in physical network
+ """
+
+ NonContigVlanIdsAcquired = False
+
+ list_physical_networks_response = PhysicalNetwork.list(
+ apiclient,
+ zoneid=zoneid
+ )
+ assert isinstance(list_physical_networks_response, list)
+ assert len(list_physical_networks_response) > 0, "No physical networks found in zone %s" % zoneid
+
+ for physical_network in list_physical_networks_response:
+
+ vlans = xsplit(physical_network.vlan, ['-', ','])
+
+ assert len(vlans) > 0
+ assert int(vlans[0]) < int(vlans[-1]), "VLAN range %s was improperly split" % physical_network.vlan
+
+ # Keep some gap between existing vlan and the new vlans which we are going to add
+ # So that they are non contiguous
+
+ non_contig_end_vlan_id = int(vlans[-1]) + 6
+ non_contig_start_vlan_id = int(vlans[0]) - 6
+
+ # Form ranges which are consecutive to existing ranges but not immediately contiguous
+ # There should be gap in between existing range and new non contiguous ranage
+
+ # If you can't add range after existing range, because it's crossing 4095, then
+ # select VLAN ids before the existing range such that they are greater than 0, and
+ # then add this non contiguoud range
+ vlan = { "partial_range": ["",""], "full_range": ""}
+
+ if non_contig_end_vlan_id < 4095:
+ vlan["partial_range"][0] = str(non_contig_end_vlan_id - 4) + '-' + str(non_contig_end_vlan_id - 3)
+ vlan["partial_range"][1] = str(non_contig_end_vlan_id - 1) + '-' + str(non_contig_end_vlan_id)
+ vlan["full_range"] = str(non_contig_end_vlan_id - 4) + '-' + str(non_contig_end_vlan_id)
+ NonContigVlanIdsAcquired = True
+
+ elif non_contig_start_vlan_id > 0:
+ vlan["partial_range"][0] = str(non_contig_start_vlan_id) + '-' + str(non_contig_start_vlan_id + 1)
+ vlan["partial_range"][1] = str(non_contig_start_vlan_id + 3) + '-' + str(non_contig_start_vlan_id + 4)
+ vlan["full_range"] = str(non_contig_start_vlan_id) + '-' + str(non_contig_start_vlan_id + 4)
+ NonContigVlanIdsAcquired = True
+
+ else:
+ NonContigVlanIdsAcquired = False
+
+ # If failed to get relevant vlan ids, continue to next physical network
+ # else break from loop as we have hot the non contiguous vlan ids for the test purpose
+
+ if not NonContigVlanIdsAcquired:
+ continue
+ else:
+ break
+
+ # If even through looping from all existing physical networks, failed to get relevant non
+ # contiguous vlan ids, then fail the test case
+
+ if not NonContigVlanIdsAcquired:
+ return None, None
+
+ return physical_network, vlan
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/tools/marvin/marvin/lib/utils.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/lib/utils.py b/tools/marvin/marvin/lib/utils.py
new file mode 100644
index 0000000..957807d
--- /dev/null
+++ b/tools/marvin/marvin/lib/utils.py
@@ -0,0 +1,472 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+"""Utilities functions
+"""
+
+import marvin
+import os
+import time
+import logging
+import string
+import random
+import imaplib
+import email
+import socket
+import urlparse
+import datetime
+from platform import system
+from marvin.cloudstackAPI import cloudstackAPIClient, listHosts
+from cloudstackException import GetDetailExceptionInfo
+from marvin.sshClient import SshClient
+from marvin.codes import (
+ SUCCESS,
+ FAIL,
+ PASS,
+ MATCH_NOT_FOUND,
+ INVALID_INPUT,
+ EMPTY_LIST,
+ FAILED)
+
+def restart_mgmt_server(server):
+ """Restarts the management server"""
+
+ try:
+ # Get the SSH client
+ ssh = is_server_ssh_ready(
+ server["ipaddress"],
+ server["port"],
+ server["username"],
+ server["password"],
+ )
+ result = ssh.execute("/etc/init.d/cloud-management restart")
+ res = str(result)
+ # Server Stop - OK
+ # Server Start - OK
+ if res.count("OK") != 2:
+ raise ("ErrorInReboot!")
+ except Exception as e:
+ raise e
+ return
+
+
+def fetch_latest_mail(services, from_mail):
+ """Fetch mail"""
+
+ # Login to mail server to verify email
+ mail = imaplib.IMAP4_SSL(services["server"])
+ mail.login(
+ services["email"],
+ services["password"]
+ )
+ mail.list()
+ mail.select(services["folder"])
+ date = (datetime.date.today() - datetime.timedelta(1)).strftime("%d-%b-%Y")
+
+ result, data = mail.uid(
+ 'search',
+ None,
+ '(SENTSINCE {date} HEADER FROM "{mail}")'.format(
+ date=date,
+ mail=from_mail
+ )
+ )
+ # Return False if email is not present
+ if data == []:
+ return False
+
+ latest_email_uid = data[0].split()[-1]
+ result, data = mail.uid('fetch', latest_email_uid, '(RFC822)')
+ raw_email = data[0][1]
+ email_message = email.message_from_string(raw_email)
+ result = get_first_text_block(email_message)
+ return result
+
+
+def get_first_text_block(email_message_instance):
+ """fetches first text block from the mail"""
+ maintype = email_message_instance.get_content_maintype()
+ if maintype == 'multipart':
+ for part in email_message_instance.get_payload():
+ if part.get_content_maintype() == 'text':
+ return part.get_payload()
+ elif maintype == 'text':
+ return email_message_instance.get_payload()
+
+
+def random_gen(id=None, size=6, chars=string.ascii_uppercase + string.digits):
+ """Generate Random Strings of variable length"""
+ randomstr = ''.join(random.choice(chars) for x in range(size))
+ if id:
+ return ''.join([id, '-', randomstr])
+ return randomstr
+
+
+def cleanup_resources(api_client, resources):
+ """Delete resources"""
+ for obj in resources:
+ obj.delete(api_client)
+
+
+def is_server_ssh_ready(ipaddress, port, username, password, retries=20, retryinterv=30, timeout=10.0, keyPairFileLocation=None):
+ '''
+ @Name: is_server_ssh_ready
+ @Input: timeout: tcp connection timeout flag,
+ others information need to be added
+ @Output:object for SshClient
+ Name of the function is little misnomer and is not
+ verifying anything as such mentioned
+ '''
+
+ try:
+ ssh = SshClient(
+ host=ipaddress,
+ port=port,
+ user=username,
+ passwd=password,
+ keyPairFiles=keyPairFileLocation,
+ retries=retries,
+ delay=retryinterv,
+ timeout=timeout)
+ except Exception, e:
+ raise Exception("SSH connection has Failed. Waited %ss. Error is %s" % (retries * retryinterv, str(e)))
+ else:
+ return ssh
+
+
+def format_volume_to_ext3(ssh_client, device="/dev/sda"):
+ """Format attached storage to ext3 fs"""
+ cmds = [
+ "echo -e 'n\np\n1\n\n\nw' | fdisk %s" % device,
+ "mkfs.ext3 %s1" % device,
+ ]
+ for c in cmds:
+ ssh_client.execute(c)
+
+
+def fetch_api_client(config_file='datacenterCfg'):
+ """Fetch the Cloudstack API Client"""
+ config = marvin.configGenerator.get_setup_config(config_file)
+ mgt = config.mgtSvr[0]
+ testClientLogger = logging.getLogger("testClient")
+ asyncTimeout = 3600
+ return cloudstackAPIClient.CloudStackAPIClient(
+ marvin.cloudstackConnection.cloudConnection(
+ mgt,
+ asyncTimeout,
+ testClientLogger
+ )
+ )
+
+def get_host_credentials(config, hostip):
+ """Get login information for a host `hostip` (ipv4) from marvin's `config`
+
+ @return the tuple username, password for the host else raise keyerror"""
+ for zone in config.zones:
+ for pod in zone.pods:
+ for cluster in pod.clusters:
+ for host in cluster.hosts:
+ if str(host.url).startswith('http'):
+ hostname = urlparse.urlsplit(str(host.url)).netloc
+ else:
+ hostname = str(host.url)
+ try:
+ if socket.getfqdn(hostip) == socket.getfqdn(hostname):
+ return host.username, host.password
+ except socket.error, e:
+ raise Exception("Unresolvable host %s error is %s" % (hostip, e))
+ raise KeyError("Please provide the marvin configuration file with credentials to your hosts")
+
+
+def get_process_status(hostip, port, username, password, linklocalip, process, hypervisor=None):
+ """Double hop and returns a process status"""
+
+ #SSH to the machine
+ ssh = SshClient(hostip, port, username, password)
+ if str(hypervisor).lower() == 'vmware':
+ ssh_command = "ssh -i /var/cloudstack/management/.ssh/id_rsa -ostricthostkeychecking=no "
+ else:
+ ssh_command = "ssh -i ~/.ssh/id_rsa.cloud -ostricthostkeychecking=no "
+
+ ssh_command = ssh_command +\
+ "-oUserKnownHostsFile=/dev/null -p 3922 %s %s" % (
+ linklocalip,
+ process)
+
+ # Double hop into router
+ timeout = 5
+ # Ensure the SSH login is successful
+ while True:
+ res = ssh.execute(ssh_command)
+
+ if res[0] != "Host key verification failed.":
+ break
+ elif timeout == 0:
+ break
+
+ time.sleep(5)
+ timeout = timeout - 1
+ return res
+
+
+def isAlmostEqual(first_digit, second_digit, range=0):
+ digits_equal_within_range = False
+
+ try:
+ if ((first_digit - range) < second_digit < (first_digit + range)):
+ digits_equal_within_range = True
+ except Exception as e:
+ raise e
+ return digits_equal_within_range
+
+
+def xsplit(txt, seps):
+ """
+ Split a string in `txt` by list of delimiters in `seps`
+ @param txt: string to split
+ @param seps: list of separators
+ @return: list of split units
+ """
+ default_sep = seps[0]
+ for sep in seps[1:]: # we skip seps[0] because that's the default separator
+ txt = txt.replace(sep, default_sep)
+ return [i.strip() for i in txt.split(default_sep)]
+
+def get_hypervisor_type(apiclient):
+
+ """Return the hypervisor type of the hosts in setup"""
+
+ cmd = listHosts.listHostsCmd()
+ cmd.type = 'Routing'
+ cmd.listall = True
+ hosts = apiclient.listHosts(cmd)
+ hosts_list_validation_result = validateList(hosts)
+ assert hosts_list_validation_result[0] == PASS, "host list validation failed"
+ return hosts_list_validation_result[1].hypervisor
+
+def is_snapshot_on_nfs(apiclient, dbconn, config, zoneid, snapshotid):
+ """
+ Checks whether a snapshot with id (not UUID) `snapshotid` is present on the nfs storage
+
+ @param apiclient: api client connection
+ @param @dbconn: connection to the cloudstack db
+ @param config: marvin configuration file
+ @param zoneid: uuid of the zone on which the secondary nfs storage pool is mounted
+ @param snapshotid: uuid of the snapshot
+ @return: True if snapshot is found, False otherwise
+ """
+ # snapshot extension to be appended to the snapshot path obtained from db
+ snapshot_extensions = {"vmware": ".ovf",
+ "kvm": "",
+ "xenserver": ".vhd"}
+
+ qresultset = dbconn.execute(
+ "select id from snapshots where uuid = '%s';" \
+ % str(snapshotid)
+ )
+ if len(qresultset) == 0:
+ raise Exception(
+ "No snapshot found in cloudstack with id %s" % snapshotid)
+
+
+ snapshotid = qresultset[0][0]
+ qresultset = dbconn.execute(
+ "select install_path,store_id from snapshot_store_ref where snapshot_id='%s' and store_role='Image';" % snapshotid
+ )
+
+ assert isinstance(qresultset, list), "Invalid db query response for snapshot %s" % snapshotid
+
+ if len(qresultset) == 0:
+ #Snapshot does not exist
+ return False
+
+ from base import ImageStore
+ #pass store_id to get the exact storage pool where snapshot is stored
+ secondaryStores = ImageStore.list(apiclient, zoneid=zoneid, id=int(qresultset[0][1]))
+
+ assert isinstance(secondaryStores, list), "Not a valid response for listImageStores"
+ assert len(secondaryStores) != 0, "No image stores found in zone %s" % zoneid
+
+ secondaryStore = secondaryStores[0]
+
+ if str(secondaryStore.providername).lower() != "nfs":
+ raise Exception(
+ "is_snapshot_on_nfs works only against nfs secondary storage. found %s" % str(secondaryStore.providername))
+
+ hypervisor = get_hypervisor_type(apiclient)
+ # append snapshot extension based on hypervisor, to the snapshot path
+ snapshotPath = str(qresultset[0][0]) + snapshot_extensions[str(hypervisor).lower()]
+
+ nfsurl = secondaryStore.url
+ from urllib2 import urlparse
+ parse_url = urlparse.urlsplit(nfsurl, scheme='nfs')
+ host, path = parse_url.netloc, parse_url.path
+
+ if not config.mgtSvr:
+ raise Exception("Your marvin configuration does not contain mgmt server credentials")
+ mgtSvr, user, passwd = config.mgtSvr[0].mgtSvrIp, config.mgtSvr[0].user, config.mgtSvr[0].passwd
+
+ try:
+ ssh_client = SshClient(
+ mgtSvr,
+ 22,
+ user,
+ passwd
+ )
+ cmds = [
+ "mkdir -p %s /mnt/tmp",
+ "mount -t %s %s%s /mnt/tmp" % (
+ 'nfs',
+ host,
+ path,
+ ),
+ "test -f %s && echo 'snapshot exists'" % (
+ os.path.join("/mnt/tmp", snapshotPath)
+ ),
+ ]
+
+ for c in cmds:
+ result = ssh_client.execute(c)
+
+ # Unmount the Sec Storage
+ cmds = [
+ "cd",
+ "umount /mnt/tmp",
+ ]
+ for c in cmds:
+ ssh_client.execute(c)
+ except Exception as e:
+ raise Exception("SSH failed for management server: %s - %s" %
+ (config.mgtSvr[0].mgtSvrIp, e))
+ return 'snapshot exists' in result
+
+def validateList(inp):
+ """
+ @name: validateList
+ @Description: 1. A utility function to validate
+ whether the input passed is a list
+ 2. The list is empty or not
+ 3. If it is list and not empty, return PASS and first element
+ 4. If not reason for FAIL
+ @Input: Input to be validated
+ @output: List, containing [ Result,FirstElement,Reason ]
+ Ist Argument('Result') : FAIL : If it is not a list
+ If it is list but empty
+ PASS : If it is list and not empty
+ IInd Argument('FirstElement'): If it is list and not empty,
+ then first element
+ in it, default to None
+ IIIrd Argument( 'Reason' ): Reason for failure ( FAIL ),
+ default to None.
+ INVALID_INPUT
+ EMPTY_LIST
+ """
+ ret = [FAIL, None, None]
+ if inp is None:
+ ret[2] = INVALID_INPUT
+ return ret
+ if not isinstance(inp, list):
+ ret[2] = INVALID_INPUT
+ return ret
+ if len(inp) == 0:
+ ret[2] = EMPTY_LIST
+ return ret
+ return [PASS, inp[0], None]
+
+def verifyElementInList(inp, toverify, responsevar=None, pos=0):
+ '''
+ @name: verifyElementInList
+ @Description:
+ 1. A utility function to validate
+ whether the input passed is a list.
+ The list is empty or not.
+ If it is list and not empty, verify
+ whether a given element is there in that list or not
+ at a given pos
+ @Input:
+ I : Input to be verified whether its a list or not
+ II : Element to verify whether it exists in the list
+ III : variable name in response object to verify
+ default to None, if None, we will verify for the complete
+ first element EX: state of response object object
+ IV : Position in the list at which the input element to verify
+ default to 0
+ @output: List, containing [ Result,Reason ]
+ Ist Argument('Result') : FAIL : If it is not a list
+ If it is list but empty
+ PASS : If it is list and not empty
+ and matching element was found
+ IIrd Argument( 'Reason' ): Reason for failure ( FAIL ),
+ default to None.
+ INVALID_INPUT
+ EMPTY_LIST
+ MATCH_NOT_FOUND
+ '''
+ if toverify is None or toverify == '' \
+ or pos is None or pos < -1 or pos == '':
+ return [FAIL, INVALID_INPUT]
+ out = validateList(inp)
+ if out[0] == FAIL:
+ return [FAIL, out[2]]
+ if len(inp) > pos:
+ if responsevar is None:
+ if inp[pos] == toverify:
+ return [PASS, None]
+ else:
+ if responsevar in inp[pos].__dict__ and getattr(inp[pos], responsevar) == toverify:
+ return [PASS, None]
+ else:
+ return [FAIL, MATCH_NOT_FOUND]
+ else:
+ return [FAIL, MATCH_NOT_FOUND]
+
+
+def checkVolumeSize(ssh_handle=None,
+ volume_name="/dev/sda",
+ cmd_inp="/sbin/fdisk -l | grep Disk",
+ size_to_verify=0):
+ '''
+ @Name : getDiskUsage
+ @Desc : provides facility to verify the volume size against the size to verify
+ @Input: 1. ssh_handle : machine against which to execute the disk size cmd
+ 2. volume_name : The name of the volume against which to verify the size
+ 3. cmd_inp : Input command used to veify the size
+ 4. size_to_verify: size against which to compare.
+ @Output: Returns FAILED in case of an issue, else SUCCESS
+ '''
+ try:
+ if ssh_handle is None or cmd_inp is None or volume_name is None:
+ return INVALID_INPUT
+
+ cmd = cmd_inp
+ '''
+ Retrieve the cmd output
+ '''
+ if system().lower() != "windows":
+ fdisk_output = ssh_handle.runCommand(cmd_inp)
+ if fdisk_output["status"] != SUCCESS:
+ return FAILED
+ temp_out = fdisk_output["stdout"]
+ for line in temp_out.split("\n"):
+ if volume_name in line:
+ parts = line.split()
+ if str(parts[-2]) == str(size_to_verify):
+ return [SUCCESS,str(parts[-2])]
+ return [FAILED,"Volume Not Found"]
+ except Exception, e:
+ print "\n Exception Occurred under getDiskUsage: " \
+ "%s" %GetDetailExceptionInfo(e)
+ return [FAILED,GetDetailExceptionInfo(e)]
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/tools/marvin/setup.py
----------------------------------------------------------------------
diff --git a/tools/marvin/setup.py b/tools/marvin/setup.py
index 9ce3951..699fe32 100644
--- a/tools/marvin/setup.py
+++ b/tools/marvin/setup.py
@@ -43,8 +43,8 @@ setup(name="Marvin",
long_description="Marvin is the Apache CloudStack python client written around the unittest framework",
platforms=("Any",),
url="https://builds.apache.org/job/cloudstack-marvin/",
- packages=["marvin", "marvin.cloudstackAPI", "marvin.integration",
- "marvin.integration.lib", "marvin.sandbox",
+ packages=["marvin", "marvin.cloudstackAPI",
+ "marvin.lib", "marvin.sandbox",
"marvin.sandbox.advanced", "marvin.sandbox.advancedsg", "marvin.sandbox.basic"],
license="LICENSE.txt",
install_requires=[
[4/6] CLOUDSTACK-6006: Remove integration folder and lib
Posted by gi...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/tools/marvin/marvin/integration/lib/base.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/integration/lib/base.py b/tools/marvin/marvin/integration/lib/base.py
deleted file mode 100755
index aa23029..0000000
--- a/tools/marvin/marvin/integration/lib/base.py
+++ /dev/null
@@ -1,3625 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-""" Base class for all Cloudstack resources
- -Virtual machine, Volume, Snapshot etc
-"""
-
-import marvin
-from utils import is_server_ssh_ready, random_gen
-from marvin.cloudstackAPI import *
-# Import System modules
-import time
-import hashlib
-import base64
-
-
-class Domain:
- """ Domain Life Cycle """
- def __init__(self, items):
- self.__dict__.update(items)
-
- @classmethod
- def create(cls, apiclient, services, name=None, networkdomain=None,
- parentdomainid=None):
- """Creates an domain"""
-
- cmd = createDomain.createDomainCmd()
-
- if "domainUUID" in services:
- cmd.domainid = "-".join([services["domainUUID"], random_gen()])
-
- if name:
- cmd.name = "-".join([name, random_gen()])
- elif "name" in services:
- cmd.name = "-".join([services["name"], random_gen()])
-
- if networkdomain:
- cmd.networkdomain = networkdomain
- elif "networkdomain" in services:
- cmd.networkdomain = services["networkdomain"]
-
- if parentdomainid:
- cmd.parentdomainid = parentdomainid
- elif "parentdomainid" in services:
- cmd.parentdomainid = services["parentdomainid"]
- try:
- domain = apiclient.createDomain(cmd)
- if domain is not None:
- return Domain(domain.__dict__)
- except Exception as e:
- raise e
-
- def delete(self, apiclient, cleanup=None):
- """Delete an domain"""
- cmd = deleteDomain.deleteDomainCmd()
- cmd.id = self.id
- if cleanup:
- cmd.cleanup = cleanup
- apiclient.deleteDomain(cmd)
-
- @classmethod
- def list(cls, apiclient, **kwargs):
- """Lists domains"""
- cmd = listDomains.listDomainsCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listDomains(cmd))
-
-
-class Account:
- """ Account Life Cycle """
- def __init__(self, items):
- self.__dict__.update(items)
-
- @classmethod
- def create(cls, apiclient, services, admin=False, domainid=None):
- """Creates an account"""
- cmd = createAccount.createAccountCmd()
-
- # 0 - User, 1 - Root Admin, 2 - Domain Admin
- cmd.accounttype = 2 if (admin and domainid) else int(admin)
-
- cmd.email = services["email"]
- cmd.firstname = services["firstname"]
- cmd.lastname = services["lastname"]
-
- cmd.password = services["password"]
-
- username = "-".join([services["username"], random_gen(id=apiclient.id)])
- # Trim username to 99 characters to prevent failure
- cmd.username = username[:99] if len(username) > 99 else username
-
- if "accountUUID" in services:
- cmd.accountid = "-".join([services["accountUUID"],random_gen()])
-
- if "userUUID" in services:
- cmd.userid = "-".join([services["userUUID"],random_gen()])
-
-
- if domainid:
- cmd.domainid = domainid
- account = apiclient.createAccount(cmd)
-
- return Account(account.__dict__)
-
- def delete(self, apiclient):
- """Delete an account"""
- cmd = deleteAccount.deleteAccountCmd()
- cmd.id = self.id
- apiclient.deleteAccount(cmd)
-
- @classmethod
- def list(cls, apiclient, **kwargs):
- """Lists accounts and provides detailed account information for
- listed accounts"""
-
- cmd = listAccounts.listAccountsCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listAccounts(cmd))
-
-
-class User:
- """ User Life Cycle """
- def __init__(self, items):
- self.__dict__.update(items)
-
- @classmethod
- def create(cls, apiclient, services, account, domainid):
- cmd = createUser.createUserCmd()
- """Creates an user"""
-
- cmd.account = account
- cmd.domainid = domainid
- cmd.email = services["email"]
- cmd.firstname = services["firstname"]
- cmd.lastname = services["lastname"]
-
- if "userUUID" in services:
- cmd.userid = "-".join([services["userUUID"],random_gen()])
-
- cmd.password = services["password"]
- cmd.username = "-".join([services["username"], random_gen()])
- user = apiclient.createUser(cmd)
-
- return User(user.__dict__)
-
- def delete(self, apiclient):
- """Delete an account"""
- cmd = deleteUser.deleteUserCmd()
- cmd.id = self.id
- apiclient.deleteUser(cmd)
-
- @classmethod
- def list(cls, apiclient, **kwargs):
- """Lists users and provides detailed account information for
- listed users"""
-
- cmd = listUsers.listUsersCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listUsers(cmd))
-
- @classmethod
- def registerUserKeys(cls, apiclient, userid):
- cmd = registerUserKeys.registerUserKeysCmd()
- cmd.id = userid
- return apiclient.registerUserKeys(cmd)
-
- def update(self, apiclient, **kwargs):
- """Updates the user details"""
-
- cmd = updateUser.updateUserCmd()
- cmd.id = self.id
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return (apiclient.updateUser(cmd))
-
- @classmethod
- def update(cls, apiclient, id, **kwargs):
- """Updates the user details (class method)"""
-
- cmd = updateUser.updateUserCmd()
- cmd.id = id
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return (apiclient.updateUser(cmd))
-
- @classmethod
- def login(cls, apiclient, username, password, domain=None, domainid=None):
- """Logins to the CloudStack"""
-
- cmd = login.loginCmd()
- cmd.username = username
- cmd.password = password
- if domain:
- cmd.domain = domain
- if domainid:
- cmd.domainId = domainid
- return apiclient.login(cmd)
-
-
-class VirtualMachine:
- """Manage virtual machine lifecycle"""
-
- def __init__(self, items, services):
- self.__dict__.update(items)
- if "username" in services:
- self.username = services["username"]
- else:
- self.username = 'root'
- if "password" in services:
- self.password = services["password"]
- else:
- self.password = 'password'
- if "ssh_port" in services:
- self.ssh_port = services["ssh_port"]
- else:
- self.ssh_port = 22
- self.ssh_client = None
- # extract out the ipaddress
- self.ipaddress = self.nic[0].ipaddress
-
- @classmethod
- def ssh_access_group(cls, apiclient, cmd):
- """
- Programs the security group with SSH access before deploying virtualmachine
- @return:
- """
- zone_list = Zone.list(
- apiclient,
- id=cmd.zoneid if cmd.zoneid else None,
- domainid=cmd.domainid if cmd.domainid else None
- )
- zone = zone_list[0]
- #check if security groups settings is enabled for the zone
- if zone.securitygroupsenabled:
- list_security_groups = SecurityGroup.list(
- apiclient,
- account=cmd.account,
- domainid=cmd.domainid,
- securitygroupname="basic_sec_grp"
- )
-
- if not isinstance(list_security_groups, list):
- basic_mode_security_group = SecurityGroup.create(
- apiclient,
- {"name": "basic_sec_grp"},
- cmd.account,
- cmd.domainid,
- )
- sec_grp_services = {
- "protocol": "TCP",
- "startport": 22,
- "endport": 22,
- "cidrlist": "0.0.0.0/0"
- }
- #Authorize security group for above ingress rule
- basic_mode_security_group.authorize(apiclient, sec_grp_services, account=cmd.account,
- domainid=cmd.domainid)
- else:
- basic_mode_security_group = list_security_groups[0]
-
- if isinstance(cmd.securitygroupids, list):
- cmd.securitygroupids.append(basic_mode_security_group.id)
- else:
- cmd.securitygroupids = [basic_mode_security_group.id]
-
- @classmethod
- def access_ssh_over_nat(cls, apiclient, services, virtual_machine, allow_egress=False):
- """
- Program NAT and PF rules to open up ssh access to deployed guest
- @return:
- """
- public_ip = PublicIPAddress.create(
- apiclient=apiclient,
- accountid=virtual_machine.account,
- zoneid=virtual_machine.zoneid,
- domainid=virtual_machine.domainid,
- services=services
- )
- FireWallRule.create(
- apiclient=apiclient,
- ipaddressid=public_ip.ipaddress.id,
- protocol='TCP',
- cidrlist=['0.0.0.0/0'],
- startport=22,
- endport=22
- )
- nat_rule = NATRule.create(
- apiclient=apiclient,
- virtual_machine=virtual_machine,
- services=services,
- ipaddressid=public_ip.ipaddress.id
- )
- if allow_egress:
- EgressFireWallRule.create(
- apiclient=apiclient,
- networkid=virtual_machine.nic[0].networkid,
- protocol='All',
- cidrlist='0.0.0.0/0'
- )
- virtual_machine.ssh_ip = nat_rule.ipaddress
- virtual_machine.public_ip = nat_rule.ipaddress
-
- @classmethod
- def create(cls, apiclient, services, templateid=None, accountid=None,
- domainid=None, zoneid=None, networkids=None, serviceofferingid=None,
- securitygroupids=None, projectid=None, startvm=None,
- diskofferingid=None, affinitygroupnames=None, affinitygroupids=None, group=None,
- hostid=None, keypair=None, ipaddress=None, mode='default', method='GET'):
- """Create the instance"""
-
- cmd = deployVirtualMachine.deployVirtualMachineCmd()
-
- if serviceofferingid:
- cmd.serviceofferingid = serviceofferingid
- elif "serviceoffering" in services:
- cmd.serviceofferingid = services["serviceoffering"]
-
- if zoneid:
- cmd.zoneid = zoneid
- elif "zoneid" in services:
- cmd.zoneid = services["zoneid"]
- cmd.hypervisor = apiclient.hypervisor
-
- if "displayname" in services:
- cmd.displayname = services["displayname"]
-
- if "name" in services:
- cmd.name = services["name"]
-
- if accountid:
- cmd.account = accountid
- elif "account" in services:
- cmd.account = services["account"]
-
- if domainid:
- cmd.domainid = domainid
- elif "domainid" in services:
- cmd.domainid = services["domainid"]
-
- if networkids:
- cmd.networkids = networkids
- allow_egress = False
- elif "networkids" in services:
- cmd.networkids = services["networkids"]
- allow_egress = False
- else:
- # When no networkids are passed, network
- # is created using the "defaultOfferingWithSourceNAT"
- # which has an egress policy of DENY. But guests in tests
- # need access to test network connectivity
- allow_egress = True
-
- if templateid:
- cmd.templateid = templateid
- elif "template" in services:
- cmd.templateid = services["template"]
-
- if diskofferingid:
- cmd.diskofferingid = diskofferingid
- elif "diskoffering" in services:
- cmd.diskofferingid = services["diskoffering"]
-
- if keypair:
- cmd.keypair = keypair
- elif "keypair" in services:
- cmd.keypair = services["keypair"]
-
- if ipaddress:
- cmd.ipaddress = ipaddress
- elif ipaddress in services:
- cmd.ipaddress = services["ipaddress"]
-
- if securitygroupids:
- cmd.securitygroupids = [str(sg_id) for sg_id in securitygroupids]
-
- if "affinitygroupnames" in services:
- cmd.affinitygroupnames = services["affinitygroupnames"]
- elif affinitygroupnames:
- cmd.affinitygroupnames = affinitygroupnames
-
- if affinitygroupids:
- cmd.affinitygroupids = affinitygroupids
-
- if projectid:
- cmd.projectid = projectid
-
- if startvm is not None:
- cmd.startvm = startvm
-
- if hostid:
- cmd.hostid = hostid
-
- if "userdata" in services:
- cmd.userdata = base64.urlsafe_b64encode(services["userdata"])
-
- if group:
- cmd.group = group
-
- #program default access to ssh
- if mode.lower() == 'basic':
- cls.ssh_access_group(apiclient, cmd)
-
- virtual_machine = apiclient.deployVirtualMachine(cmd, method=method)
-
- virtual_machine.ssh_ip = virtual_machine.nic[0].ipaddress
- if startvm == False:
- virtual_machine.public_ip = virtual_machine.nic[0].ipaddress
- return VirtualMachine(virtual_machine.__dict__, services)
-
- #program ssh access over NAT via PF
- if mode.lower() == 'advanced':
- cls.access_ssh_over_nat(apiclient, services, virtual_machine, allow_egress=allow_egress)
- elif mode.lower() == 'basic':
- if virtual_machine.publicip is not None:
- vm_ssh_ip = virtual_machine.publicip #EIP/ELB (netscaler) enabled zone
- else:
- vm_ssh_ip = virtual_machine.nic[0].ipaddress #regular basic zone with security group
- virtual_machine.ssh_ip = vm_ssh_ip
- virtual_machine.public_ip = vm_ssh_ip
-
- return VirtualMachine(virtual_machine.__dict__, services)
-
- def start(self, apiclient):
- """Start the instance"""
- cmd = startVirtualMachine.startVirtualMachineCmd()
- cmd.id = self.id
- apiclient.startVirtualMachine(cmd)
-
- def stop(self, apiclient):
- """Stop the instance"""
- cmd = stopVirtualMachine.stopVirtualMachineCmd()
- cmd.id = self.id
- apiclient.stopVirtualMachine(cmd)
-
- def reboot(self, apiclient):
- """Reboot the instance"""
- cmd = rebootVirtualMachine.rebootVirtualMachineCmd()
- cmd.id = self.id
- apiclient.rebootVirtualMachine(cmd)
-
- def recover(self, apiclient):
- """Recover the instance"""
- cmd = recoverVirtualMachine.recoverVirtualMachineCmd()
- cmd.id = self.id
- apiclient.recoverVirtualMachine(cmd)
-
- def restore(self, apiclient, templateid=None):
- """Restore the instance"""
- cmd = restoreVirtualMachine.restoreVirtualMachineCmd()
- cmd.virtualmachineid = self.id
- if templateid:
- cmd.templateid = templateid
- return apiclient.restoreVirtualMachine(cmd)
-
- def get_ssh_client(self, ipaddress=None, reconnect=False, port=None, keyPairFileLocation=None):
- """Get SSH object of VM"""
-
- # If NAT Rules are not created while VM deployment in Advanced mode
- # then, IP address must be passed
- if ipaddress != None:
- self.ssh_ip = ipaddress
- if port:
- self.ssh_port = port
-
- if keyPairFileLocation is not None:
- self.password = None
-
- if reconnect:
- self.ssh_client = is_server_ssh_ready(
- self.ssh_ip,
- self.ssh_port,
- self.username,
- self.password,
- keyPairFileLocation=keyPairFileLocation
- )
- self.ssh_client = self.ssh_client or is_server_ssh_ready(
- self.ssh_ip,
- self.ssh_port,
- self.username,
- self.password,
- keyPairFileLocation=keyPairFileLocation
- )
- return self.ssh_client
-
- def resetSshKey(self, apiclient, **kwargs):
- """Resets SSH key"""
-
- cmd = resetSSHKeyForVirtualMachine.resetSSHKeyForVirtualMachineCmd()
- cmd.id = self.id
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.resetSSHKeyForVirtualMachine(cmd))
-
- def update(self, apiclient, **kwargs):
- """Updates the VM data"""
-
- cmd = updateVirtualMachine.updateVirtualMachineCmd()
- cmd.id = self.id
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.updateVirtualMachine(cmd))
-
- def delete(self, apiclient):
- """Destroy an Instance"""
- cmd = destroyVirtualMachine.destroyVirtualMachineCmd()
- cmd.id = self.id
- apiclient.destroyVirtualMachine(cmd)
-
- def migrate(self, apiclient, hostid=None):
- """migrate an Instance"""
- cmd = migrateVirtualMachine.migrateVirtualMachineCmd()
- cmd.virtualmachineid = self.id
- if hostid:
- cmd.hostid = hostid
- apiclient.migrateVirtualMachine(cmd)
-
- def attach_volume(self, apiclient, volume):
- """Attach volume to instance"""
- cmd = attachVolume.attachVolumeCmd()
- cmd.id = volume.id
- cmd.virtualmachineid = self.id
- return apiclient.attachVolume(cmd)
-
- def detach_volume(self, apiclient, volume):
- """Detach volume to instance"""
- cmd = detachVolume.detachVolumeCmd()
- cmd.id = volume.id
- return apiclient.detachVolume(cmd)
-
- def add_nic(self, apiclient, networkId, ipaddress=None):
- """Add a NIC to a VM"""
- cmd = addNicToVirtualMachine.addNicToVirtualMachineCmd()
- cmd.virtualmachineid = self.id
- cmd.networkid = networkId
-
- if ipaddress:
- cmd.ipaddress = ipaddress
-
- return apiclient.addNicToVirtualMachine(cmd)
-
- def remove_nic(self, apiclient, nicId):
- """Remove a NIC to a VM"""
- cmd = removeNicFromVirtualMachine.removeNicFromVirtualMachineCmd()
- cmd.nicid = nicId
- cmd.virtualmachineid = self.id
- return apiclient.removeNicFromVirtualMachine(cmd)
-
- def update_default_nic(self, apiclient, nicId):
- """Set a NIC to be the default network adapter for a VM"""
- cmd = updateDefaultNicForVirtualMachine.updateDefaultNicForVirtualMachineCmd()
- cmd.nicid = nicId
- cmd.virtualmachineid = self.id
- return apiclient.updateDefaultNicForVirtualMachine(cmd)
-
- def attach_iso(self, apiclient, iso):
- """Attach ISO to instance"""
- cmd = attachIso.attachIsoCmd()
- cmd.id = iso.id
- cmd.virtualmachineid = self.id
- return apiclient.attachIso(cmd)
-
- def detach_iso(self, apiclient):
- """Detach ISO to instance"""
- cmd = detachIso.detachIsoCmd()
- cmd.id = self.id
- return apiclient.detachIso(cmd)
-
- def change_service_offering(self, apiclient, serviceOfferingId):
- """Change service offering of the instance"""
- cmd = changeServiceForVirtualMachine.changeServiceForVirtualMachineCmd()
- cmd.id = self.id
- cmd.serviceofferingid = serviceOfferingId
- return apiclient.changeServiceForVirtualMachine(cmd)
-
- @classmethod
- def list(cls, apiclient, **kwargs):
- """List all VMs matching criteria"""
-
- cmd = listVirtualMachines.listVirtualMachinesCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listVirtualMachines(cmd))
-
- def resetPassword(self, apiclient):
- """Resets VM password if VM created using password enabled template"""
-
- cmd = resetPasswordForVirtualMachine.resetPasswordForVirtualMachineCmd()
- cmd.id = self.id
- try:
- response = apiclient.resetPasswordForVirtualMachine(cmd)
- except Exception as e:
- raise Exception("Reset Password failed! - %s" % e)
- if response is not None:
- return response.password
-
- def assign_virtual_machine(self, apiclient, account, domainid):
- """Move a user VM to another user under same domain."""
-
- cmd = assignVirtualMachine.assignVirtualMachineCmd()
- cmd.virtualmachineid = self.id
- cmd.account = account
- cmd.domainid = domainid
- try:
- response = apiclient.assignVirtualMachine(cmd)
- return response
- except Exception as e:
- raise Exception("assignVirtualMachine failed - %s" %e)
-
- def update_affinity_group(self, apiclient, affinitygroupids=None,
- affinitygroupnames=None):
- """Update affinity group of a VM"""
- cmd = updateVMAffinityGroup.updateVMAffinityGroupCmd()
- cmd.id = self.id
-
- if affinitygroupids:
- cmd.affinitygroupids = affinitygroupids
-
- if affinitygroupnames:
- cmd.affinitygroupnames = affinitygroupnames
-
- return apiclient.updateVMAffinityGroup(cmd)
-
-
-class Volume:
- """Manage Volume Life cycle
- """
- def __init__(self, items):
- self.__dict__.update(items)
-
- @classmethod
- def create(cls, apiclient, services, zoneid=None, account=None,
- domainid=None, diskofferingid=None, projectid=None):
- """Create Volume"""
- cmd = createVolume.createVolumeCmd()
- cmd.name = services["diskname"]
-
- if diskofferingid:
- cmd.diskofferingid = diskofferingid
- elif "diskofferingid" in services:
- cmd.diskofferingid = services["diskofferingid"]
-
- if zoneid:
- cmd.zoneid = zoneid
- elif "zoneid" in services:
- cmd.zoneid = services["zoneid"]
-
- if account:
- cmd.account = account
- elif "account" in services:
- cmd.account = services["account"]
-
- if domainid:
- cmd.domainid = domainid
- elif "domainid" in services:
- cmd.domainid = services["domainid"]
-
- if projectid:
- cmd.projectid = projectid
- return Volume(apiclient.createVolume(cmd).__dict__)
-
- @classmethod
- def create_custom_disk(cls, apiclient, services, account=None,
- domainid=None, diskofferingid=None):
- """Create Volume from Custom disk offering"""
- cmd = createVolume.createVolumeCmd()
- cmd.name = services["diskname"]
-
- if diskofferingid:
- cmd.diskofferingid = diskofferingid
- elif "customdiskofferingid" in services:
- cmd.diskofferingid = services["customdiskofferingid"]
-
- cmd.size = services["customdisksize"]
- cmd.zoneid = services["zoneid"]
-
- if account:
- cmd.account = account
- else:
- cmd.account = services["account"]
-
- if domainid:
- cmd.domainid = domainid
- else:
- cmd.domainid = services["domainid"]
-
- return Volume(apiclient.createVolume(cmd).__dict__)
-
- @classmethod
- def create_from_snapshot(cls, apiclient, snapshot_id, services,
- account=None, domainid=None):
- """Create Volume from snapshot"""
- cmd = createVolume.createVolumeCmd()
- cmd.name = "-".join([services["diskname"], random_gen()])
- cmd.snapshotid = snapshot_id
- cmd.zoneid = services["zoneid"]
- cmd.size = services["size"]
- if account:
- cmd.account = account
- else:
- cmd.account = services["account"]
- if domainid:
- cmd.domainid = domainid
- else:
- cmd.domainid = services["domainid"]
- return Volume(apiclient.createVolume(cmd).__dict__)
-
- def delete(self, apiclient):
- """Delete Volume"""
- cmd = deleteVolume.deleteVolumeCmd()
- cmd.id = self.id
- apiclient.deleteVolume(cmd)
-
- @classmethod
- def list(cls, apiclient, **kwargs):
- """List all volumes matching criteria"""
-
- cmd = listVolumes.listVolumesCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listVolumes(cmd))
-
- def resize(self, apiclient, **kwargs):
- """Resize a volume"""
- cmd = resizeVolume.resizeVolumeCmd()
- cmd.id = self.id
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.resizeVolume(cmd))
-
- @classmethod
- def upload(cls, apiclient, services, zoneid=None, account=None, domainid=None, url=None):
- """Uploads the volume to specified account"""
-
- cmd = uploadVolume.uploadVolumeCmd()
- if zoneid:
- cmd.zoneid = zoneid
- if account:
- cmd.account = account
- if domainid:
- cmd.domainid = domainid
- cmd.format = services["format"]
- cmd.name = services["diskname"]
- if url:
- cmd.url = url
- else:
- cmd.url = services["url"]
- return Volume(apiclient.uploadVolume(cmd).__dict__)
-
- def wait_for_upload(self, apiclient, timeout=10, interval=60):
- """Wait for upload"""
- # Sleep to ensure template is in proper state before download
- time.sleep(interval)
-
- while True:
- volume_response = Volume.list(
- apiclient,
- id=self.id,
- zoneid=self.zoneid,
- )
- if isinstance(volume_response, list):
-
- volume = volume_response[0]
- # If volume is ready,
- # volume.state = Allocated
- if volume.state == 'Uploaded':
- break
-
- elif 'Uploading' in volume.state:
- time.sleep(interval)
-
- elif 'Installing' not in volume.state:
- raise Exception(
- "Error in uploading volume: status - %s" %
- volume.state)
- elif timeout == 0:
- break
-
- else:
- time.sleep(interval)
- timeout = timeout - 1
- return
-
- @classmethod
- def migrate(cls, apiclient, **kwargs):
- """Migrate a volume"""
- cmd = migrateVolume.migrateVolumeCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.migrateVolume(cmd))
-
-class Snapshot:
- """Manage Snapshot Lifecycle
- """
- def __init__(self, items):
- self.__dict__.update(items)
-
- @classmethod
- def create(cls, apiclient, volume_id, account=None,
- domainid=None, projectid=None):
- """Create Snapshot"""
- cmd = createSnapshot.createSnapshotCmd()
- cmd.volumeid = volume_id
- if account:
- cmd.account = account
- if domainid:
- cmd.domainid = domainid
- if projectid:
- cmd.projectid = projectid
- return Snapshot(apiclient.createSnapshot(cmd).__dict__)
-
- def delete(self, apiclient):
- """Delete Snapshot"""
- cmd = deleteSnapshot.deleteSnapshotCmd()
- cmd.id = self.id
- apiclient.deleteSnapshot(cmd)
-
- @classmethod
- def list(cls, apiclient, **kwargs):
- """List all snapshots matching criteria"""
-
- cmd = listSnapshots.listSnapshotsCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listSnapshots(cmd))
-
-
-class Template:
- """Manage template life cycle"""
-
- def __init__(self, items):
- self.__dict__.update(items)
-
- @classmethod
- def create(cls, apiclient, services, volumeid=None,
- account=None, domainid=None, projectid=None):
- """Create template from Volume"""
- # Create template from Virtual machine and Volume ID
- cmd = createTemplate.createTemplateCmd()
- cmd.displaytext = services["displaytext"]
- cmd.name = "-".join([services["name"], random_gen()])
- if "ostypeid" in services:
- cmd.ostypeid = services["ostypeid"]
- elif "ostype" in services:
- # Find OSTypeId from Os type
- sub_cmd = listOsTypes.listOsTypesCmd()
- sub_cmd.description = services["ostype"]
- ostypes = apiclient.listOsTypes(sub_cmd)
-
- if not isinstance(ostypes, list):
- raise Exception(
- "Unable to find Ostype id with desc: %s" %
- services["ostype"])
- cmd.ostypeid = ostypes[0].id
- else:
- raise Exception(
- "Unable to find Ostype is required for creating template")
-
- cmd.isfeatured = services["isfeatured"] if "isfeatured" in services else False
- cmd.ispublic = services["ispublic"] if "ispublic" in services else False
- cmd.isextractable = services["isextractable"] if "isextractable" in services else False
- cmd.passwordenabled = services["passwordenabled"] if "passwordenabled" in services else False
-
- if volumeid:
- cmd.volumeid = volumeid
-
- if account:
- cmd.account = account
-
- if domainid:
- cmd.domainid = domainid
-
- if projectid:
- cmd.projectid = projectid
- return Template(apiclient.createTemplate(cmd).__dict__)
-
- @classmethod
- def register(cls, apiclient, services, zoneid=None,
- account=None, domainid=None):
- """Create template from URL"""
-
- # Create template from Virtual machine and Volume ID
- cmd = registerTemplate.registerTemplateCmd()
- cmd.displaytext = services["displaytext"]
- cmd.name = "-".join([services["name"], random_gen()])
- cmd.format = services["format"]
- cmd.hypervisor = apiclient.hypervisor
-
- if "ostypeid" in services:
- cmd.ostypeid = services["ostypeid"]
- elif "ostype" in services:
- # Find OSTypeId from Os type
- sub_cmd = listOsTypes.listOsTypesCmd()
- sub_cmd.description = services["ostype"]
- ostypes = apiclient.listOsTypes(sub_cmd)
-
- if not isinstance(ostypes, list):
- raise Exception(
- "Unable to find Ostype id with desc: %s" %
- services["ostype"])
- cmd.ostypeid = ostypes[0].id
- else:
- raise Exception(
- "Unable to find Ostype is required for registering template")
-
- cmd.url = services["url"]
-
- if zoneid:
- cmd.zoneid = zoneid
- else:
- cmd.zoneid = services["zoneid"]
-
- cmd.isfeatured = services["isfeatured"] if "isfeatured" in services else False
- cmd.ispublic = services["ispublic"] if "ispublic" in services else False
- cmd.isextractable = services["isextractable"] if "isextractable" in services else False
- cmd.passwordenabled = services["passwordenabled"] if "passwordenabled" in services else False
-
- if account:
- cmd.account = account
-
- if domainid:
- cmd.domainid = domainid
-
- # Register Template
- template = apiclient.registerTemplate(cmd)
-
- if isinstance(template, list):
- return Template(template[0].__dict__)
-
- @classmethod
- def extract(cls, apiclient, id, mode, zoneid=None):
- "Extract template "
-
- cmd = extractTemplate.extractTemplateCmd()
- cmd.id = id
- cmd.mode = mode
- cmd.zoneid = zoneid
-
- return apiclient.extractTemplate(cmd)
-
- @classmethod
- def create_from_snapshot(cls, apiclient, snapshot, services,
- random_name=True):
- """Create Template from snapshot"""
- # Create template from Virtual machine and Snapshot ID
- cmd = createTemplate.createTemplateCmd()
- cmd.displaytext = services["displaytext"]
- cmd.name = "-".join([
- services["name"],
- random_gen()
- ]) if random_name else services["name"]
-
- if "ostypeid" in services:
- cmd.ostypeid = services["ostypeid"]
- elif "ostype" in services:
- # Find OSTypeId from Os type
- sub_cmd = listOsTypes.listOsTypesCmd()
- sub_cmd.description = services["ostype"]
- ostypes = apiclient.listOsTypes(sub_cmd)
-
- if not isinstance(ostypes, list):
- raise Exception(
- "Unable to find Ostype id with desc: %s" %
- services["ostype"])
- cmd.ostypeid = ostypes[0].id
- else:
- raise Exception(
- "Unable to find Ostype is required for creating template")
-
- cmd.snapshotid = snapshot.id
- return Template(apiclient.createTemplate(cmd).__dict__)
-
- def delete(self, apiclient):
- """Delete Template"""
-
- cmd = deleteTemplate.deleteTemplateCmd()
- cmd.id = self.id
- apiclient.deleteTemplate(cmd)
-
- def download(self, apiclient, timeout=5, interval=60):
- """Download Template"""
- # Sleep to ensure template is in proper state before download
- time.sleep(interval)
-
- while True:
- template_response = Template.list(
- apiclient,
- id=self.id,
- zoneid=self.zoneid,
- templatefilter='self'
- )
- if isinstance(template_response, list):
-
- template = template_response[0]
- # If template is ready,
- # template.status = Download Complete
- # Downloading - x% Downloaded
- # Error - Any other string
- if template.status == 'Download Complete':
- break
-
- elif 'Downloaded' in template.status:
- time.sleep(interval)
-
- elif 'Installing' not in template.status:
- raise Exception(
- "Error in downloading template: status - %s" %
- template.status)
-
- elif timeout == 0:
- break
-
- else:
- time.sleep(interval)
- timeout = timeout - 1
- return
-
- def updatePermissions(self, apiclient, **kwargs):
- """Updates the template permissions"""
-
- cmd = updateTemplatePermissions.updateTemplatePermissionsCmd()
- cmd.id = self.id
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.updateTemplatePermissions(cmd))
-
- @classmethod
- def list(cls, apiclient, **kwargs):
- """List all templates matching criteria"""
-
- cmd = listTemplates.listTemplatesCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listTemplates(cmd))
-
-
-class Iso:
- """Manage ISO life cycle"""
-
- def __init__(self, items):
- self.__dict__.update(items)
-
- @classmethod
- def create(cls, apiclient, services, account=None, domainid=None,
- projectid=None):
- """Create an ISO"""
- # Create ISO from URL
- cmd = registerIso.registerIsoCmd()
- cmd.displaytext = services["displaytext"]
- cmd.name = services["name"]
- if "ostypeid" in services:
- cmd.ostypeid = services["ostypeid"]
- elif "ostype" in services:
- # Find OSTypeId from Os type
- sub_cmd = listOsTypes.listOsTypesCmd()
- sub_cmd.description = services["ostype"]
- ostypes = apiclient.listOsTypes(sub_cmd)
-
- if not isinstance(ostypes, list):
- raise Exception(
- "Unable to find Ostype id with desc: %s" %
- services["ostype"])
- cmd.ostypeid = ostypes[0].id
- else:
- raise Exception(
- "Unable to find Ostype is required for creating ISO")
-
- cmd.url = services["url"]
- cmd.zoneid = services["zoneid"]
-
- if "isextractable" in services:
- cmd.isextractable = services["isextractable"]
- if "isfeatured" in services:
- cmd.isfeatured = services["isfeatured"]
- if "ispublic" in services:
- cmd.ispublic = services["ispublic"]
-
- if account:
- cmd.account = account
- if domainid:
- cmd.domainid = domainid
- if projectid:
- cmd.projectid = projectid
- # Register ISO
- iso = apiclient.registerIso(cmd)
-
- if iso:
- return Iso(iso[0].__dict__)
-
- def delete(self, apiclient):
- """Delete an ISO"""
- cmd = deleteIso.deleteIsoCmd()
- cmd.id = self.id
- apiclient.deleteIso(cmd)
- return
-
- def download(self, apiclient, timeout=5, interval=60):
- """Download an ISO"""
- # Ensuring ISO is successfully downloaded
- while True:
- time.sleep(interval)
-
- cmd = listIsos.listIsosCmd()
- cmd.id = self.id
- iso_response = apiclient.listIsos(cmd)
-
- if isinstance(iso_response, list):
- response = iso_response[0]
- # Again initialize timeout to avoid listISO failure
- timeout = 5
- # Check whether download is in progress(for Ex:10% Downloaded)
- # or ISO is 'Successfully Installed'
- if response.status == 'Successfully Installed':
- return
- elif 'Downloaded' not in response.status and \
- 'Installing' not in response.status:
- raise Exception(
- "Error In Downloading ISO: ISO Status - %s" %
- response.status)
-
- elif timeout == 0:
- raise Exception("ISO download Timeout Exception")
- else:
- timeout = timeout - 1
- return
-
- @classmethod
- def list(cls, apiclient, **kwargs):
- """Lists all available ISO files."""
-
- cmd = listIsos.listIsosCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listIsos(cmd))
-
-
-class PublicIPAddress:
- """Manage Public IP Addresses"""
-
- def __init__(self, items):
- self.__dict__.update(items)
-
- @classmethod
- def create(cls, apiclient, accountid=None, zoneid=None, domainid=None, services=None,
- networkid=None, projectid=None, vpcid=None, isportable=False):
- """Associate Public IP address"""
- cmd = associateIpAddress.associateIpAddressCmd()
-
- if accountid:
- cmd.account = accountid
- elif "account" in services:
- cmd.account = services["account"]
-
- if zoneid:
- cmd.zoneid = zoneid
- elif "zoneid" in services:
- cmd.zoneid = services["zoneid"]
-
- if domainid:
- cmd.domainid = domainid
- elif "domainid" in services:
- cmd.domainid = services["domainid"]
-
- if isportable:
- cmd.isportable = isportable
-
- if networkid:
- cmd.networkid = networkid
-
- if projectid:
- cmd.projectid = projectid
-
- if vpcid:
- cmd.vpcid = vpcid
- return PublicIPAddress(apiclient.associateIpAddress(cmd).__dict__)
-
- def delete(self, apiclient):
- """Dissociate Public IP address"""
- cmd = disassociateIpAddress.disassociateIpAddressCmd()
- cmd.id = self.ipaddress.id
- apiclient.disassociateIpAddress(cmd)
- return
-
- @classmethod
- def list(cls, apiclient, **kwargs):
- """List all Public IPs matching criteria"""
-
- cmd = listPublicIpAddresses.listPublicIpAddressesCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listPublicIpAddresses(cmd))
-
-
-class NATRule:
- """Manage port forwarding rule"""
-
- def __init__(self, items):
- self.__dict__.update(items)
-
- @classmethod
- def create(cls, apiclient, virtual_machine, services, ipaddressid=None,
- projectid=None, openfirewall=False, networkid=None, vpcid=None):
- """Create Port forwarding rule"""
- cmd = createPortForwardingRule.createPortForwardingRuleCmd()
-
- if ipaddressid:
- cmd.ipaddressid = ipaddressid
- elif "ipaddressid" in services:
- cmd.ipaddressid = services["ipaddressid"]
-
- cmd.privateport = services["privateport"]
- cmd.publicport = services["publicport"]
- if "privateendport" in services:
- cmd.privateendport = services["privateendport"]
- if "publicendport" in services:
- cmd.publicendport = services["publicendport"]
- cmd.protocol = services["protocol"]
- cmd.virtualmachineid = virtual_machine.id
-
- if projectid:
- cmd.projectid = projectid
-
- if openfirewall:
- cmd.openfirewall = True
-
- if networkid:
- cmd.networkid = networkid
-
- if vpcid:
- cmd.vpcid = vpcid
- return NATRule(apiclient.createPortForwardingRule(cmd).__dict__)
-
- def delete(self, apiclient):
- """Delete port forwarding"""
- cmd = deletePortForwardingRule.deletePortForwardingRuleCmd()
- cmd.id = self.id
- apiclient.deletePortForwardingRule(cmd)
- return
-
- @classmethod
- def list(cls, apiclient, **kwargs):
- """List all NAT rules matching criteria"""
-
- cmd = listPortForwardingRules.listPortForwardingRulesCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listPortForwardingRules(cmd))
-
-
-class StaticNATRule:
- """Manage Static NAT rule"""
-
- def __init__(self, items):
- self.__dict__.update(items)
-
- @classmethod
- def create(cls, apiclient, services, ipaddressid=None, networkid=None, vpcid=None):
- """Creates static ip forwarding rule"""
-
- cmd = createFirewallRule.createFirewallRuleCmd()
- cmd.protocol = services["protocol"]
- cmd.startport = services["startport"]
-
- if "endport" in services:
- cmd.endport = services["endport"]
-
- if "cidrlist" in services:
- cmd.cidrlist = services["cidrlist"]
-
- if ipaddressid:
- cmd.ipaddressid = ipaddressid
- elif "ipaddressid" in services:
- cmd.ipaddressid = services["ipaddressid"]
-
- if networkid:
- cmd.networkid = networkid
-
- if vpcid:
- cmd.vpcid = vpcid
- return StaticNATRule(apiclient.createFirewallRule(cmd).__dict__)
-
- def delete(self, apiclient):
- """Delete IP forwarding rule"""
- cmd = deleteIpForwardingRule.deleteIpForwardingRuleCmd()
- cmd.id = self.id
- apiclient.deleteIpForwardingRule(cmd)
- return
-
- @classmethod
- def list(cls, apiclient, **kwargs):
- """List all IP forwarding rules matching criteria"""
-
- cmd = listIpForwardingRules.listIpForwardingRulesCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listIpForwardingRules(cmd))
-
- @classmethod
- def enable(cls, apiclient, ipaddressid, virtualmachineid, networkid=None):
- """Enables Static NAT rule"""
-
- cmd = enableStaticNat.enableStaticNatCmd()
- cmd.ipaddressid = ipaddressid
- cmd.virtualmachineid = virtualmachineid
- if networkid:
- cmd.networkid = networkid
- apiclient.enableStaticNat(cmd)
- return
-
- @classmethod
- def disable(cls, apiclient, ipaddressid, virtualmachineid):
- """Disables Static NAT rule"""
-
- cmd = disableStaticNat.disableStaticNatCmd()
- cmd.ipaddressid = ipaddressid
- apiclient.disableStaticNat(cmd)
- return
-
-
-class EgressFireWallRule:
- """Manage Egress Firewall rule"""
-
- def __init__(self, items):
- self.__dict__.update(items)
-
- @classmethod
- def create(cls, apiclient, networkid, protocol, cidrlist=None,
- startport=None, endport=None):
- """Create Egress Firewall Rule"""
- cmd = createEgressFirewallRule.createEgressFirewallRuleCmd()
- cmd.networkid = networkid
- cmd.protocol = protocol
- if cidrlist:
- cmd.cidrlist = cidrlist
- if startport:
- cmd.startport = startport
- if endport:
- cmd.endport = endport
-
- return EgressFireWallRule(apiclient.createEgressFirewallRule(cmd).__dict__)
-
- def delete(self, apiclient):
- """Delete Egress Firewall rule"""
- cmd = deleteEgressFirewallRule.deleteEgressFirewallRuleCmd()
- cmd.id = self.id
- apiclient.deleteEgressFirewallRule(cmd)
- return
-
- @classmethod
- def list(cls, apiclient, **kwargs):
- """List all Egress Firewall Rules matching criteria"""
-
- cmd = listEgressFirewallRules.listEgressFirewallRulesCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listEgressFirewallRules(cmd))
-
-
-
-class FireWallRule:
- """Manage Firewall rule"""
-
- def __init__(self, items):
- self.__dict__.update(items)
-
- @classmethod
- def create(cls, apiclient, ipaddressid, protocol, cidrlist=None,
- startport=None, endport=None, projectid=None, vpcid=None):
- """Create Firewall Rule"""
- cmd = createFirewallRule.createFirewallRuleCmd()
- cmd.ipaddressid = ipaddressid
- cmd.protocol = protocol
- if cidrlist:
- cmd.cidrlist = cidrlist
- if startport:
- cmd.startport = startport
- if endport:
- cmd.endport = endport
-
- if projectid:
- cmd.projectid = projectid
-
- if vpcid:
- cmd.vpcid = vpcid
-
- return FireWallRule(apiclient.createFirewallRule(cmd).__dict__)
-
- def delete(self, apiclient):
- """Delete Firewall rule"""
- cmd = deleteFirewallRule.deleteFirewallRuleCmd()
- cmd.id = self.id
- apiclient.deleteFirewallRule(cmd)
- return
-
- @classmethod
- def list(cls, apiclient, **kwargs):
- """List all Firewall Rules matching criteria"""
-
- cmd = listFirewallRules.listFirewallRulesCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listFirewallRules(cmd))
-
-
-class ServiceOffering:
- """Manage service offerings cycle"""
-
- def __init__(self, items):
- self.__dict__.update(items)
-
- @classmethod
- def create(cls, apiclient, services, domainid=None, **kwargs):
- """Create Service offering"""
- cmd = createServiceOffering.createServiceOfferingCmd()
- cmd.cpunumber = services["cpunumber"]
- cmd.cpuspeed = services["cpuspeed"]
- cmd.displaytext = services["displaytext"]
- cmd.memory = services["memory"]
- cmd.name = services["name"]
- if "storagetype" in services:
- cmd.storagetype = services["storagetype"]
-
- if "systemvmtype" in services:
- cmd.systemvmtype = services['systemvmtype']
-
- if "issystem" in services:
- cmd.issystem = services['issystem']
-
- if "tags" in services:
- cmd.tags = services["tags"]
-
- if "deploymentplanner" in services:
- cmd.deploymentplanner = services["deploymentplanner"]
-
- if "isvolatile" in services:
- cmd.isvolatile = services["isvolatile"]
-
- # Service Offering private to that domain
- if domainid:
- cmd.domainid = domainid
-
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return ServiceOffering(apiclient.createServiceOffering(cmd).__dict__)
-
- def delete(self, apiclient):
- """Delete Service offering"""
- cmd = deleteServiceOffering.deleteServiceOfferingCmd()
- cmd.id = self.id
- apiclient.deleteServiceOffering(cmd)
- return
-
- @classmethod
- def list(cls, apiclient, **kwargs):
- """Lists all available service offerings."""
-
- cmd = listServiceOfferings.listServiceOfferingsCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listServiceOfferings(cmd))
-
-
-class DiskOffering:
- """Manage disk offerings cycle"""
-
- def __init__(self, items):
- self.__dict__.update(items)
-
- @classmethod
- def create(cls, apiclient, services, custom=False, domainid=None):
- """Create Disk offering"""
- cmd = createDiskOffering.createDiskOfferingCmd()
- cmd.displaytext = services["displaytext"]
- cmd.name = services["name"]
- if custom:
- cmd.customized = True
- else:
- cmd.disksize = services["disksize"]
-
- if domainid:
- cmd.domainid = domainid
-
- if "storagetype" in services:
- cmd.storagetype = services["storagetype"]
-
- return DiskOffering(apiclient.createDiskOffering(cmd).__dict__)
-
- def delete(self, apiclient):
- """Delete Disk offering"""
- cmd = deleteDiskOffering.deleteDiskOfferingCmd()
- cmd.id = self.id
- apiclient.deleteDiskOffering(cmd)
- return
-
- @classmethod
- def list(cls, apiclient, **kwargs):
- """Lists all available disk offerings."""
-
- cmd = listDiskOfferings.listDiskOfferingsCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listDiskOfferings(cmd))
-
-
-class NetworkOffering:
- """Manage network offerings cycle"""
-
- def __init__(self, items):
- self.__dict__.update(items)
-
- @classmethod
- def create(cls, apiclient, services, **kwargs):
- """Create network offering"""
-
- cmd = createNetworkOffering.createNetworkOfferingCmd()
- cmd.displaytext = "-".join([services["displaytext"], random_gen()])
- cmd.name = "-".join([services["name"], random_gen()])
- cmd.guestiptype = services["guestiptype"]
- cmd.supportedservices = ''
- if "supportedservices" in services:
- cmd.supportedservices = services["supportedservices"]
- cmd.traffictype = services["traffictype"]
-
- if "useVpc" in services:
- cmd.useVpc = services["useVpc"]
- cmd.serviceproviderlist = []
- if "serviceProviderList" in services:
- for service, provider in services["serviceProviderList"].items():
- cmd.serviceproviderlist.append({
- 'service': service,
- 'provider': provider
- })
- if "serviceCapabilityList" in services:
- cmd.servicecapabilitylist = []
- for service, capability in services["serviceCapabilityList"].items():
- for ctype, value in capability.items():
- cmd.servicecapabilitylist.append({
- 'service': service,
- 'capabilitytype': ctype,
- 'capabilityvalue': value
- })
- if "specifyVlan" in services:
- cmd.specifyVlan = services["specifyVlan"]
- if "specifyIpRanges" in services:
- cmd.specifyIpRanges = services["specifyIpRanges"]
- if "ispersistent" in services:
- cmd.ispersistent = services["ispersistent"]
- if "egress_policy" in services:
- cmd.egressdefaultpolicy = services["egress_policy"]
-
- cmd.availability = 'Optional'
-
- [setattr(cmd, k, v) for k, v in kwargs.items()]
-
- return NetworkOffering(apiclient.createNetworkOffering(cmd).__dict__)
-
- def delete(self, apiclient):
- """Delete network offering"""
- cmd = deleteNetworkOffering.deleteNetworkOfferingCmd()
- cmd.id = self.id
- apiclient.deleteNetworkOffering(cmd)
- return
-
- def update(self, apiclient, **kwargs):
- """Lists all available network offerings."""
-
- cmd = updateNetworkOffering.updateNetworkOfferingCmd()
- cmd.id = self.id
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.updateNetworkOffering(cmd))
-
- @classmethod
- def list(cls, apiclient, **kwargs):
- """Lists all available network offerings."""
-
- cmd = listNetworkOfferings.listNetworkOfferingsCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listNetworkOfferings(cmd))
-
-
-class SnapshotPolicy:
- """Manage snapshot policies"""
-
- def __init__(self, items):
- self.__dict__.update(items)
-
- @classmethod
- def create(cls, apiclient, volumeid, services):
- """Create Snapshot policy"""
- cmd = createSnapshotPolicy.createSnapshotPolicyCmd()
- cmd.intervaltype = services["intervaltype"]
- cmd.maxsnaps = services["maxsnaps"]
- cmd.schedule = services["schedule"]
- cmd.timezone = services["timezone"]
- cmd.volumeid = volumeid
- return SnapshotPolicy(apiclient.createSnapshotPolicy(cmd).__dict__)
-
- def delete(self, apiclient):
- """Delete Snapshot policy"""
- cmd = deleteSnapshotPolicies.deleteSnapshotPoliciesCmd()
- cmd.id = self.id
- apiclient.deleteSnapshotPolicies(cmd)
- return
-
- @classmethod
- def list(cls, apiclient, **kwargs):
- """Lists snapshot policies."""
-
- cmd = listSnapshotPolicies.listSnapshotPoliciesCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listSnapshotPolicies(cmd))
-
-
-class LoadBalancerRule:
- """Manage Load Balancer rule"""
-
- def __init__(self, items):
- self.__dict__.update(items)
-
- @classmethod
- def create(cls, apiclient, services, ipaddressid=None, accountid=None,
- networkid=None, vpcid=None, projectid=None, domainid=None):
- """Create Load balancing Rule"""
-
- cmd = createLoadBalancerRule.createLoadBalancerRuleCmd()
-
- if ipaddressid:
- cmd.publicipid = ipaddressid
- elif "ipaddressid" in services:
- cmd.publicipid = services["ipaddressid"]
-
- if accountid:
- cmd.account = accountid
- elif "account" in services:
- cmd.account = services["account"]
-
- if domainid:
- cmd.domainid = domainid
-
- if vpcid:
- cmd.vpcid = vpcid
- cmd.name = services["name"]
- cmd.algorithm = services["alg"]
- cmd.privateport = services["privateport"]
- cmd.publicport = services["publicport"]
-
- if "openfirewall" in services:
- cmd.openfirewall = services["openfirewall"]
-
- if projectid:
- cmd.projectid = projectid
-
- if networkid:
- cmd.networkid = networkid
- return LoadBalancerRule(apiclient.createLoadBalancerRule(cmd).__dict__)
-
- def delete(self, apiclient):
- """Delete load balancing rule"""
- cmd = deleteLoadBalancerRule.deleteLoadBalancerRuleCmd()
- cmd.id = self.id
- apiclient.deleteLoadBalancerRule(cmd)
- return
-
- def assign(self, apiclient, vms):
- """Assign virtual machines to load balancing rule"""
- cmd = assignToLoadBalancerRule.assignToLoadBalancerRuleCmd()
- cmd.id = self.id
- cmd.virtualmachineids = [str(vm.id) for vm in vms]
- apiclient.assignToLoadBalancerRule(cmd)
- return
-
- def remove(self, apiclient, vms):
- """Remove virtual machines from load balancing rule"""
- cmd = removeFromLoadBalancerRule.removeFromLoadBalancerRuleCmd()
- cmd.id = self.id
- cmd.virtualmachineids = [str(vm.id) for vm in vms]
- apiclient.removeFromLoadBalancerRule(cmd)
- return
-
- def update(self, apiclient, algorithm=None, description=None, name=None, **kwargs):
- """Updates the load balancing rule"""
- cmd = updateLoadBalancerRule.updateLoadBalancerRuleCmd()
- cmd.id = self.id
- if algorithm:
- cmd.algorithm = algorithm
- if description:
- cmd.description = description
- if name:
- cmd.name = name
-
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return apiclient.updateLoadBalancerRule(cmd)
-
- def createSticky(self, apiclient, methodname, name, description=None, param=None):
- """Creates a sticky policy for the LB rule"""
-
- cmd = createLBStickinessPolicy.createLBStickinessPolicyCmd()
- cmd.lbruleid = self.id
- cmd.methodname = methodname
- cmd.name = name
- if description:
- cmd.description = description
- if param:
- cmd.param = []
- for name, value in param.items():
- cmd.param.append({'name': name, 'value': value})
- return apiclient.createLBStickinessPolicy(cmd)
-
- def deleteSticky(self, apiclient, id):
- """Deletes stickyness policy"""
-
- cmd = deleteLBStickinessPolicy.deleteLBStickinessPolicyCmd()
- cmd.id = id
- return apiclient.deleteLBStickinessPolicy(cmd)
-
- @classmethod
- def listStickyPolicies(cls, apiclient, lbruleid, **kwargs):
- """Lists stickiness policies for load balancing rule"""
-
- cmd = listLBStickinessPolicies.listLBStickinessPoliciesCmd()
- cmd.lbruleid = lbruleid
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return apiclient.listLBStickinessPolicies(cmd)
-
- @classmethod
- def list(cls, apiclient, **kwargs):
- """List all Load balancing rules matching criteria"""
-
- cmd = listLoadBalancerRules.listLoadBalancerRulesCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listLoadBalancerRules(cmd))
-
-
-class Cluster:
- """Manage Cluster life cycle"""
-
- def __init__(self, items):
- self.__dict__.update(items)
-
- @classmethod
- def create(cls, apiclient, services, zoneid=None, podid=None):
- """Create Cluster"""
- cmd = addCluster.addClusterCmd()
- cmd.clustertype = services["clustertype"]
- cmd.hypervisor = apiclient.hypervisor
-
- if zoneid:
- cmd.zoneid = zoneid
- else:
- cmd.zoneid = services["zoneid"]
-
- if podid:
- cmd.podid = podid
- else:
- cmd.podid = services["podid"]
-
- if "username" in services:
- cmd.username = services["username"]
- if "password" in services:
- cmd.password = services["password"]
- if "url" in services:
- cmd.url = services["url"]
- if "clustername" in services:
- cmd.clustername = services["clustername"]
-
- return Cluster(apiclient.addCluster(cmd)[0].__dict__)
-
- def delete(self, apiclient):
- """Delete Cluster"""
- cmd = deleteCluster.deleteClusterCmd()
- cmd.id = self.id
- apiclient.deleteCluster(cmd)
- return
-
- @classmethod
- def list(cls, apiclient, **kwargs):
- """List all Clusters matching criteria"""
-
- cmd = listClusters.listClustersCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listClusters(cmd))
-
-
-class Host:
- """Manage Host life cycle"""
-
- def __init__(self, items):
- self.__dict__.update(items)
-
- @classmethod
- def create(cls, apiclient, cluster, services, zoneid=None, podid=None):
- """Create Host in cluster"""
-
- cmd = addHost.addHostCmd()
- cmd.hypervisor = apiclient.hypervisor
- cmd.url = services["url"]
- cmd.clusterid = cluster.id
-
- if zoneid:
- cmd.zoneid = zoneid
- else:
- cmd.zoneid = services["zoneid"]
-
- if podid:
- cmd.podid = podid
- else:
- cmd.podid = services["podid"]
-
- if "clustertype" in services:
- cmd.clustertype = services["clustertype"]
- if "username" in services:
- cmd.username = services["username"]
- if "password" in services:
- cmd.password = services["password"]
-
- # Add host
- host = apiclient.addHost(cmd)
-
- if isinstance(host, list):
- return Host(host[0].__dict__)
-
- def delete(self, apiclient):
- """Delete Host"""
- # Host must be in maintenance mode before deletion
- cmd = prepareHostForMaintenance.prepareHostForMaintenanceCmd()
- cmd.id = self.id
- apiclient.prepareHostForMaintenance(cmd)
- time.sleep(30)
-
- cmd = deleteHost.deleteHostCmd()
- cmd.id = self.id
- apiclient.deleteHost(cmd)
- return
-
- def enableMaintenance(self, apiclient):
- """enables maintenance mode Host"""
-
- cmd = prepareHostForMaintenance.prepareHostForMaintenanceCmd()
- cmd.id = self.id
- return apiclient.prepareHostForMaintenance(cmd)
-
- @classmethod
- def enableMaintenance(cls, apiclient, id):
- """enables maintenance mode Host"""
-
- cmd = prepareHostForMaintenance.prepareHostForMaintenanceCmd()
- cmd.id = id
- return apiclient.prepareHostForMaintenance(cmd)
-
- def cancelMaintenance(self, apiclient):
- """Cancels maintenance mode Host"""
-
- cmd = cancelHostMaintenance.cancelHostMaintenanceCmd()
- cmd.id = self.id
- return apiclient.cancelHostMaintenance(cmd)
-
- @classmethod
- def cancelMaintenance(cls, apiclient, id):
- """Cancels maintenance mode Host"""
-
- cmd = cancelHostMaintenance.cancelHostMaintenanceCmd()
- cmd.id = id
- return apiclient.cancelHostMaintenance(cmd)
-
- @classmethod
- def list(cls, apiclient, **kwargs):
- """List all Hosts matching criteria"""
-
- cmd = listHosts.listHostsCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listHosts(cmd))
-
- @classmethod
- def listForMigration(cls, apiclient, **kwargs):
- """List all Hosts for migration matching criteria"""
-
- cmd = findHostsForMigration.findHostsForMigrationCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.findHostsForMigration(cmd))
-
- @classmethod
- def update(cls, apiclient, **kwargs):
- """Update host information"""
-
- cmd = updateHost.updateHostCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.updateHost(cmd))
-
-
-class StoragePool:
- """Manage Storage pools (Primary Storage)"""
-
- def __init__(self, items):
- self.__dict__.update(items)
-
- @classmethod
- def create(cls, apiclient, services, clusterid=None,
- zoneid=None, podid=None):
- """Create Storage pool (Primary Storage)"""
-
- cmd = createStoragePool.createStoragePoolCmd()
- cmd.name = services["name"]
-
- if podid:
- cmd.podid = podid
- else:
- cmd.podid = services["podid"]
-
- cmd.url = services["url"]
- if clusterid:
- cmd.clusterid = clusterid
- elif "clusterid" in services:
- cmd.clusterid = services["clusterid"]
-
- if zoneid:
- cmd.zoneid = zoneid
- else:
- cmd.zoneid = services["zoneid"]
-
- return StoragePool(apiclient.createStoragePool(cmd).__dict__)
-
- def delete(self, apiclient):
- """Delete Storage pool (Primary Storage)"""
-
- # Storage pool must be in maintenance mode before deletion
- cmd = enableStorageMaintenance.enableStorageMaintenanceCmd()
- cmd.id = self.id
- apiclient.enableStorageMaintenance(cmd)
- time.sleep(30)
- cmd = deleteStoragePool.deleteStoragePoolCmd()
- cmd.id = self.id
- apiclient.deleteStoragePool(cmd)
- return
-
- def enableMaintenance(self, apiclient):
- """enables maintenance mode Storage pool"""
-
- cmd = enableStorageMaintenance.enableStorageMaintenanceCmd()
- cmd.id = self.id
- return apiclient.enableStorageMaintenance(cmd)
-
- @classmethod
- def list(cls, apiclient, **kwargs):
- """List all storage pools matching criteria"""
-
- cmd = listStoragePools.listStoragePoolsCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listStoragePools(cmd))
-
- @classmethod
- def listForMigration(cls, apiclient, **kwargs):
- """List all storage pools for migration matching criteria"""
-
- cmd = findStoragePoolsForMigration.findStoragePoolsForMigrationCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.findStoragePoolsForMigration(cmd))
-
-class Network:
- """Manage Network pools"""
-
- def __init__(self, items):
- self.__dict__.update(items)
-
- @classmethod
- def create(cls, apiclient, services, accountid=None, domainid=None,
- networkofferingid=None, projectid=None,
- subdomainaccess=None, zoneid=None,
- gateway=None, netmask=None, vpcid=None, aclid=None):
- """Create Network for account"""
- cmd = createNetwork.createNetworkCmd()
- cmd.name = services["name"]
- cmd.displaytext = services["displaytext"]
-
- if networkofferingid:
- cmd.networkofferingid = networkofferingid
- elif "networkoffering" in services:
- cmd.networkofferingid = services["networkoffering"]
-
- if zoneid:
- cmd.zoneid = zoneid
- elif "zoneid" in services:
- cmd.zoneid = services["zoneid"]
-
- if subdomainaccess is not None:
- cmd.subdomainaccess = subdomainaccess
-
- if gateway:
- cmd.gateway = gateway
- elif "gateway" in services:
- cmd.gateway = services["gateway"]
- if netmask:
- cmd.netmask = netmask
- elif "netmask" in services:
- cmd.netmask = services["netmask"]
- if "startip" in services:
- cmd.startip = services["startip"]
- if "endip" in services:
- cmd.endip = services["endip"]
- if "vlan" in services:
- cmd.vlan = services["vlan"]
- if "acltype" in services:
- cmd.acltype = services["acltype"]
-
- if accountid:
- cmd.account = accountid
- if domainid:
- cmd.domainid = domainid
- if projectid:
- cmd.projectid = projectid
- if vpcid:
- cmd.vpcid = vpcid
- if aclid:
- cmd.aclid = aclid
- return Network(apiclient.createNetwork(cmd).__dict__)
-
- def delete(self, apiclient):
- """Delete Account"""
-
- cmd = deleteNetwork.deleteNetworkCmd()
- cmd.id = self.id
- apiclient.deleteNetwork(cmd)
-
- def update(self, apiclient, **kwargs):
- """Updates network with parameters passed"""
-
- cmd = updateNetwork.updateNetworkCmd()
- cmd.id = self.id
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.updateNetwork(cmd))
-
- def restart(self, apiclient, cleanup=None):
- """Restarts the network"""
-
- cmd = restartNetwork.restartNetworkCmd()
- cmd.id = self.id
- if cleanup:
- cmd.cleanup = cleanup
- return(apiclient.restartNetwork(cmd))
-
- @classmethod
- def list(cls, apiclient, **kwargs):
- """List all Networks matching criteria"""
-
- cmd = listNetworks.listNetworksCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listNetworks(cmd))
-
-
-class NetworkACL:
- """Manage Network ACL lifecycle"""
-
- def __init__(self, items):
- self.__dict__.update(items)
-
- @classmethod
- def create(cls, apiclient, services, networkid=None, protocol=None,
- number=None, aclid=None, action='Allow', traffictype=None, cidrlist=[]):
- """Create network ACL rules(Ingress/Egress)"""
-
- cmd = createNetworkACL.createNetworkACLCmd()
- if "networkid" in services:
- cmd.networkid = services["networkid"]
- elif networkid:
- cmd.networkid = networkid
-
- if "protocol" in services:
- cmd.protocol = services["protocol"]
- if services["protocol"] == 'ICMP':
- cmd.icmptype = -1
- cmd.icmpcode = -1
- elif protocol:
- cmd.protocol = protocol
-
- if "startport" in services:
- cmd.startport = services["startport"]
- if "endport" in services:
- cmd.endport = services["endport"]
-
- if "cidrlist" in services:
- cmd.cidrlist = services["cidrlist"]
- elif cidrlist:
- cmd.cidrlist = cidrlist
-
- if "traffictype" in services:
- cmd.traffictype = services["traffictype"]
- elif traffictype:
- cmd.traffictype = traffictype
-
- if "action" in services:
- cmd.action = services["action"]
- elif action:
- cmd.action = action
-
- if "number" in services:
- cmd.number = services["number"]
- elif number:
- cmd.number = number
-
- if "aclid" in services:
- cmd.aclid = services["aclid"]
- elif aclid:
- cmd.aclid = aclid
-
- # Defaulted to Ingress
- return NetworkACL(apiclient.createNetworkACL(cmd).__dict__)
-
- def delete(self, apiclient):
- """Delete network acl"""
-
- cmd = deleteNetworkACL.deleteNetworkACLCmd()
- cmd.id = self.id
- return apiclient.deleteNetworkACL(cmd)
-
- @classmethod
- def list(cls, apiclient, **kwargs):
- """List Network ACLs"""
-
- cmd = listNetworkACLs.listNetworkACLsCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listNetworkACLs(cmd))
-
-
-class NetworkACLList:
- """Manage Network ACL lists lifecycle"""
-
- def __init__(self, items):
- self.__dict__.update(items)
-
- @classmethod
- def create(cls, apiclient, services, name=None, description=None, vpcid=None):
- """Create network ACL container list"""
-
- cmd = createNetworkACLList.createNetworkACLListCmd()
- if "name" in services:
- cmd.name = services["name"]
- elif name:
- cmd.name = name
-
- if "description" in services:
- cmd.description = services["description"]
- elif description:
- cmd.description = description
-
- if "vpcid" in services:
- cmd.vpcid = services["vpcid"]
- elif vpcid:
- cmd.vpcid = vpcid
-
- return NetworkACLList(apiclient.createNetworkACLList(cmd).__dict__)
-
- def delete(self, apiclient):
- """Delete network acl list"""
-
- cmd = deleteNetworkACLList.deleteNetworkACLListCmd()
- cmd.id = self.id
- return apiclient.deleteNetworkACLList(cmd)
-
- @classmethod
- def list(cls, apiclient, **kwargs):
- """List Network ACL lists"""
-
- cmd = listNetworkACLLists.listNetworkACLListsCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listNetworkACLLists(cmd))
-
-
-class Vpn:
- """Manage VPN life cycle"""
-
- def __init__(self, items):
- self.__dict__.update(items)
-
- @classmethod
- def create(cls, apiclient, publicipid, account=None, domainid=None,
- projectid=None, networkid=None, vpcid=None):
- """Create VPN for Public IP address"""
- cmd = createRemoteAccessVpn.createRemoteAccessVpnCmd()
- cmd.publicipid = publicipid
- if account:
- cmd.account = account
- if domainid:
- cmd.domainid = domainid
- if projectid:
- cmd.projectid = projectid
- if networkid:
- cmd.networkid = networkid
- if vpcid:
- cmd.vpcid = vpcid
- return Vpn(apiclient.createRemoteAccessVpn(cmd).__dict__)
-
- def delete(self, apiclient):
- """Delete remote VPN access"""
-
- cmd = deleteRemoteAccessVpn.deleteRemoteAccessVpnCmd()
- cmd.publicipid = self.publicipid
- apiclient.deleteRemoteAccessVpn(cmd)
-
- @classmethod
- def list(cls, apiclient, **kwargs):
- """List all VPN matching criteria"""
-
- cmd = listRemoteAccessVpns.listRemoteAccessVpnsCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listRemoteAccessVpns(cmd))
-
-
-class VpnUser:
- """Manage VPN user"""
-
- def __init__(self, items):
- self.__dict__.update(items)
-
- @classmethod
- def create(cls, apiclient, username, password, account=None, domainid=None,
- projectid=None, rand_name=True):
- """Create VPN user"""
- cmd = addVpnUser.addVpnUserCmd()
- cmd.username = "-".join([username,
- random_gen()]) if rand_name else username
- cmd.password = password
-
- if account:
- cmd.account = account
- if domainid:
- cmd.domainid = domainid
- if projectid:
- cmd.projectid = projectid
- return VpnUser(apiclient.addVpnUser(cmd).__dict__)
-
- def delete(self, apiclient, projectid=None):
- """Remove VPN user"""
-
- cmd = removeVpnUser.removeVpnUserCmd()
- cmd.username = self.username
- if projectid:
- cmd.projectid = projectid
- else:
- cmd.account = self.account
- cmd.domainid = self.domainid
- apiclient.removeVpnUser(cmd)
-
- @classmethod
- def list(cls, apiclient, **kwargs):
- """List all VPN Users matching criteria"""
-
- cmd = listVpnUsers.listVpnUsersCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listVpnUsers(cmd))
-
-
-class Zone:
- """Manage Zone"""
-
- def __init__(self, items):
- self.__dict__.update(items)
-
- @classmethod
- def create(cls, apiclient, services, domainid=None):
- """Create zone"""
- cmd = createZone.createZoneCmd()
- cmd.dns1 = services["dns1"]
- cmd.internaldns1 = services["internaldns1"]
- cmd.name = services["name"]
- cmd.networktype = services["networktype"]
-
- if "dns2" in services:
- cmd.dns2 = services["dns2"]
- if "internaldns2" in services:
- cmd.internaldns2 = services["internaldns2"]
- if domainid:
- cmd.domainid = domainid
- if "securitygroupenabled" in services:
- cmd.securitygroupenabled = services["securitygroupenabled"]
-
- return Zone(apiclient.createZone(cmd).__dict__)
-
- def delete(self, apiclient):
- """Delete Zone"""
-
- cmd = deleteZone.deleteZoneCmd()
- cmd.id = self.id
- apiclient.deleteZone(cmd)
-
- def update(self, apiclient, **kwargs):
- """Update the zone"""
-
- cmd = updateZone.updateZoneCmd()
- cmd.id = self.id
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return apiclient.updateZone(cmd)
-
- @classmethod
- def list(cls, apiclient, **kwargs):
- """List all Zones matching criteria"""
-
- cmd = listZones.listZonesCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listZones(cmd))
-
-
-class Pod:
- """Manage Pod"""
-
- def __init__(self, items):
- self.__dict__.update(items)
-
- @classmethod
- def create(cls, apiclient, services):
- """Create Pod"""
- cmd = createPod.createPodCmd()
- cmd.gateway = services["gateway"]
- cmd.netmask = services["netmask"]
- cmd.name = services["name"]
- cmd.startip = services["startip"]
- cmd.endip = services["endip"]
- cmd.zoneid = services["zoneid"]
-
- return Pod(apiclient.createPod(cmd).__dict__)
-
- def delete(self, apiclient):
- """Delete Pod"""
-
- cmd = deletePod.deletePodCmd()
- cmd.id = self.id
- apiclient.deletePod(cmd)
-
- @classmethod
- def list(cls, apiclient, **kwargs):
- "Returns a default pod for specified zone"
-
- cmd = listPods.listPodsCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return apiclient.listPods(cmd)
-
-
-class PublicIpRange:
- """Manage VlanIpRange"""
-
- def __init__(self, items):
- self.__dict__.update(items)
-
- @classmethod
- def create(cls, apiclient, services):
- """Create VlanIpRange"""
-
- cmd = createVlanIpRange.createVlanIpRangeCmd()
- cmd.gateway = services["gateway"]
- cmd.netmask = services["netmask"]
- cmd.forvirtualnetwork = services["forvirtualnetwork"]
- cmd.startip = services["startip"]
- cmd.endip = services["endip"]
- cmd.zoneid = services["zoneid"]
- cmd.podid = services["podid"]
- cmd.vlan = services["vlan"]
-
- return PublicIpRange(apiclient.createVlanIpRange(cmd).__dict__)
-
- def delete(self, apiclient):
- """Delete VlanIpRange"""
-
- cmd = deleteVlanIpRange.deleteVlanIpRangeCmd()
- cmd.id = self.vlan.id
- apiclient.deleteVlanIpRange(cmd)
-
- @classmethod
- def list(cls, apiclient, **kwargs):
- """Lists all VLAN IP ranges."""
-
- cmd = listVlanIpRanges.listVlanIpRangesCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listVlanIpRanges(cmd))
-
- @classmethod
- def dedicate(cls, apiclient, id, account=None, domainid=None, projectid=None):
- """Dedicate VLAN IP range"""
-
- cmd = dedicatePublicIpRange.dedicatePublicIpRangeCmd()
- cmd.id = id
- cmd.account = account
- cmd.domainid = domainid
- cmd.projectid = projectid
- return PublicIpRange(apiclient.dedicatePublicIpRange(cmd).__dict__)
-
- def release(self, apiclient):
- """Release VLAN IP range"""
-
- cmd = releasePublicIpRange.releasePublicIpRangeCmd()
- cmd.id = self.vlan.id
- return apiclient.releasePublicIpRange(cmd)
-
-
-class PortablePublicIpRange:
- """Manage portable public Ip Range"""
-
- def __init__(self, items):
- self.__dict__.update(items)
-
- @classmethod
- def create(cls, apiclient, services):
- """Create portable public Ip Range"""
-
- cmd = createPortableIpRange.createPortableIpRangeCmd()
- cmd.gateway = services["gateway"]
- cmd.netmask = services["netmask"]
- cmd.startip = services["startip"]
- cmd.endip = services["endip"]
- cmd.regionid = services["regionid"]
-
- if "vlan" in services:
- cmd.vlan = services["vlan"]
-
- return PortablePublicIpRange(apiclient.createPortableIpRange(cmd).__dict__)
-
- def delete(self, apiclient):
- """Delete portable IpRange"""
-
- cmd = deletePortableIpRange.deletePortableIpRangeCmd()
- cmd.id = self.id
- apiclient.deletePortableIpRange(cmd)
-
- @classmethod
- def list(cls, apiclient, **kwargs):
- """Lists all portable public IP ranges."""
-
- cmd = listPortableIpRanges.listPortableIpRangesCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listPortableIpRanges(cmd))
-
-class SecondaryStagingStore:
- """Manage Staging Store"""
-
- def __init__(self, items):
- self.__dict__.update(items)
-
- @classmethod
- def create(cls, apiclient, url, provider, services=None):
- """Create Staging Storage"""
- cmd = createSecondaryStagingStore.createSecondaryStagingStoreCmd()
- cmd.url = url
- cmd.provider = provider
- if services:
- if "zoneid" in services:
- cmd.zoneid = services["zoneid"]
- if "details" in services:
- cmd.details = services["details"]
- if "scope" in services:
- cmd.scope = services["scope"]
-
- return SecondaryStagingStore(apiclient.createSecondaryStagingStore(cmd).__dict__)
-
- def delete(self, apiclient):
- """Delete Staging Storage"""
- cmd = deleteSecondaryStagingStore.deleteSecondaryStagingStoreCmd()
- cmd.id = self.id
- apiclient.deleteSecondaryStagingStore(cmd)
-
- @classmethod
- def list(cls, apiclient, **kwargs):
- cmd = listSecondaryStagingStores.listSecondaryStagingStoresCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listSecondaryStagingStores(cmd))
-
-
-class ImageStore:
- """Manage image stores"""
-
- def __init__(self, items):
- self.__dict__.update(items)
-
- @classmethod
- def create(cls, apiclient, url, provider, services=None):
- """Add Image Store"""
- cmd = addImageStore.addImageStoreCmd()
- cmd.url = url
- cmd.provider = provider
- if services:
- if "zoneid" in services:
- cmd.zoneid = services["zoneid"]
- if "details" in services:
- cmd.details = services["details"]
- if "scope" in services:
- cmd.scope = services["scope"]
-
- return ImageStore(apiclient.addImageStore(cmd).__dict__)
-
- def delete(self, apiclient):
- """Delete Image Store"""
- cmd = deleteImageStore.deleteImageStoreCmd()
- cmd.id = self.id
- apiclient.deleteImageStore(cmd)
-
- @classmethod
- def list(cls, apiclient, **kwargs):
- cmd = listImageStores.listImageStoresCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listImageStores(cmd))
-
-
-class PhysicalNetwork:
- """Manage physical network storage"""
-
- def __init__(self, items):
- self.__dict__.update(items)
-
- @classmethod
- def create(cls, apiclient, services, zoneid, domainid=None):
- """Create physical network"""
- cmd = createPhysicalNetwork.createPhysicalNetworkCmd()
-
- cmd.name = services["name"]
- cmd.zoneid = zoneid
- if domainid:
- cmd.domainid = domainid
- return PhysicalNetwork(apiclient.createPhysicalNetwork(cmd).__dict__)
-
- def delete(self, apiclient):
- """Delete Physical Network"""
-
- cmd = deletePhysicalNetwork.deletePhysicalNetworkCmd()
- cmd.id = self.id
- apiclient.deletePhysicalNetwork(cmd)
-
- def update(self, apiclient, **kwargs):
- """Update Physical network state"""
-
- cmd = updatePhysicalNetwork.updatePhysicalNetworkCmd()
- cmd.id = self.id
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return apiclient.updatePhysicalNetwork(cmd)
-
- def addTrafficType(self, apiclient, type):
- """Add Traffic type to Physical network"""
-
- cmd = addTrafficType.addTrafficTypeCmd()
- cmd.physicalnetworkid = self.id
- cmd.traffictype = type
- return apiclient.addTrafficType(cmd)
-
- @classmethod
- def dedicate(cls, apiclient, vlanrange, physicalnetworkid, account=None, domainid=None, projectid=None):
- """Dedicate guest vlan range"""
-
- cmd = dedicateGuestVlanRange.dedicateGuestVlanRangeCmd()
- cmd.vlanrange = vlanrange
- cmd.physicalnetworkid = physicalnetworkid
- cmd.account = account
- cmd.domainid = domainid
- cmd.projectid = projectid
- return PhysicalNetwork(apiclient.dedicateGuestVlanRange(cmd).__dict__)
-
- def release(self, apiclient):
- """Release guest vlan range"""
-
- cmd = releaseDedicatedGuestVlanRange.releaseDedicatedGuestVlanRangeCmd()
- cmd.id = self.id
- return apiclient.releaseDedicatedGuestVlanRange(cmd)
-
- @classmethod
- def listDedicated(cls, apiclient, **kwargs):
- """Lists all dedicated guest vlan ranges"""
-
- cmd = listDedicatedGuestVlanRanges.listDedicatedGuestVlanRangesCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return apiclient.listDedicatedGuestVlanRanges(cmd)
-
- @classmethod
- def list(cls, apiclient, **kwargs):
- """Lists all physical networks"""
-
- cmd = listPhysicalNetworks.listPhysicalNetworksCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return map(lambda pn : PhysicalNetwork(pn.__dict__), apiclient.listPhysicalNetworks(cmd))
-
-
-class SecurityGroup:
- """Manage Security Groups"""
-
- def __init__(self, items):
- self.__dict__.update(items)
-
- @classmethod
- def create(cls, apiclient, services, account=None, domainid=None,
- description=None, projectid=None):
- """Create security group"""
- cmd = createSecurityGroup.createSecurityGroupCmd()
-
- cmd.name = services["name"]
- if account:
- cmd.account = account
- if domainid:
- cmd.domainid = domainid
- if description:
- cmd.description = description
- if projectid:
- cmd.projectid = projectid
-
- return SecurityGroup(apiclient.createSecurityGroup(cmd).__dict__)
-
- def delete(self, apiclient):
- """Delete Security Group"""
-
- cmd = deleteSecurityGroup.deleteSecurityGroupCmd()
- cmd.id = self.id
- apiclient.deleteSecurityGroup(cmd)
-
- def authorize(self, apiclient, services,
- account=None, domainid=None, projectid=None):
- """Authorize Ingress Rule"""
-
- cmd = authorizeSecurityGroupIngress.authorizeSecurityGroupIngressCmd()
-
- if domainid:
- cmd.domainid = domainid
- if account:
- cmd.account = account
-
- if projectid:
- cmd.projectid = projectid
- cmd.securitygroupid = self.id
- cmd.protocol = services["protocol"]
-
- if services["protocol"] == 'ICMP':
- cmd.icmptype = -1
- cmd.icmpcode = -1
- else:
- cmd.startport = services["startport"]
- cmd.endport = services["endport"]
-
- cmd.cidrlist = services["cidrlist"]
- return (apiclient.authorizeSecurityGroupIngress(cmd).__dict__)
-
- de
<TRUNCATED>
[6/6] git commit: updated refs/heads/marvin to bf72441
Posted by gi...@apache.org.
CLOUDSTACK-6006: Remove integration folder and lib
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/bf72441d
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/bf72441d
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/bf72441d
Branch: refs/heads/marvin
Commit: bf72441d13845a1de92c2976e3b535634bfae740
Parents: a908b8d
Author: Santhosh Edukulla <Sa...@citrix.com>
Authored: Tue Feb 4 12:01:58 2014 +0530
Committer: Girish Shilamkar <gi...@clogeny.com>
Committed: Tue Feb 4 12:01:58 2014 +0530
----------------------------------------------------------------------
.../api/test/account/testCreateAccount.py | 4 +-
.../maint/test_egress_rules_host_maintenance.py | 6 +-
.../component/maint/test_high_availability.py | 6 +-
.../maint/test_host_high_availability.py | 6 +-
.../component/maint/test_multiple_ip_ranges.py | 6 +-
.../component/maint/test_redundant_router.py | 6 +-
...test_redundant_router_deployment_planning.py | 6 +-
.../test_redundant_router_network_rules.py | 6 +-
.../maint/test_vpc_host_maintenance.py | 6 +-
.../maint/test_vpc_on_host_maintenance.py | 6 +-
test/integration/component/test_accounts.py | 6 +-
.../component/test_add_remove_network.py | 6 +-
.../component/test_advancedsg_networks.py | 6 +-
.../component/test_affinity_groups.py | 6 +-
.../component/test_allocation_states.py | 6 +-
test/integration/component/test_asa1000v_fw.py | 6 +-
test/integration/component/test_assign_vm.py | 6 +-
test/integration/component/test_baremetal.py | 6 +-
.../component/test_base_image_updation.py | 6 +-
test/integration/component/test_blocker_bugs.py | 6 +-
.../component/test_cpu_domain_limits.py | 6 +-
test/integration/component/test_cpu_limits.py | 6 +-
.../component/test_cpu_max_limits.py | 6 +-
.../component/test_cpu_project_limits.py | 6 +-
.../component/test_custom_hostname.py | 6 +-
.../component/test_deploy_vm_userdata_reg.py | 6 +-
.../component/test_egress_fw_rules.py | 6 +-
test/integration/component/test_egress_rules.py | 6 +-
test/integration/component/test_eip_elb.py | 6 +-
.../component/test_explicit_dedication.py | 6 +-
test/integration/component/test_haproxy.py | 6 +-
.../component/test_implicit_planner.py | 6 +-
.../component/test_ip_reservation.py | 6 +-
test/integration/component/test_ldap.py | 6 +-
.../integration/component/test_memory_limits.py | 6 +-
.../component/test_mm_domain_limits.py | 6 +-
.../integration/component/test_mm_max_limits.py | 6 +-
.../component/test_mm_project_limits.py | 6 +-
.../component/test_multiple_ip_ranges.py | 6 +-
.../component/test_netscaler_configs.py | 6 +-
test/integration/component/test_netscaler_lb.py | 6 +-
.../component/test_netscaler_lb_algo.py | 6 +-
.../component/test_netscaler_lb_sticky.py | 6 +-
.../component/test_netscaler_nw_off.py | 6 +-
.../component/test_network_offering.py | 6 +-
.../component/test_non_contiguous_vlan.py | 6 +-
.../component/test_persistent_networks.py | 6 +-
test/integration/component/test_portable_ip.py | 6 +-
.../component/test_project_configs.py | 6 +-
.../component/test_project_limits.py | 6 +-
.../component/test_project_resources.py | 6 +-
.../integration/component/test_project_usage.py | 6 +-
test/integration/component/test_projects.py | 6 +-
.../component/test_recurring_snapshots.py | 6 +-
.../component/test_redundant_router_cleanups.py | 6 +-
.../component/test_redundant_router_services.py | 6 +-
.../component/test_redundant_router_upgrades.py | 6 +-
test/integration/component/test_regions.py | 6 +-
.../component/test_regions_accounts.py | 6 +-
.../component/test_reset_ssh_keypair.py | 6 +-
.../component/test_resource_limits.py | 6 +-
test/integration/component/test_routers.py | 6 +-
.../component/test_security_groups.py | 6 +-
.../component/test_shared_networks.py | 6 +-
test/integration/component/test_snapshot_gc.py | 8 +-
.../component/test_snapshot_limits.py | 8 +-
test/integration/component/test_snapshots.py | 6 +-
.../component/test_snapshots_improvement.py | 6 +-
test/integration/component/test_stopped_vm.py | 6 +-
.../component/test_storage_motion.py | 6 +-
test/integration/component/test_tags.py | 6 +-
test/integration/component/test_templates.py | 6 +-
test/integration/component/test_update_vm.py | 6 +-
test/integration/component/test_usage.py | 6 +-
.../component/test_vm_passwdenabled.py | 6 +-
test/integration/component/test_vmware_drs.py | 6 +-
test/integration/component/test_volumes.py | 6 +-
test/integration/component/test_vpc.py | 6 +-
test/integration/component/test_vpc_network.py | 6 +-
.../component/test_vpc_network_lbrules.py | 6 +-
.../component/test_vpc_network_pfrules.py | 6 +-
.../component/test_vpc_network_staticnatrule.py | 6 +-
.../integration/component/test_vpc_offerings.py | 6 +-
test/integration/component/test_vpc_routers.py | 6 +-
.../component/test_vpc_vm_life_cycle.py | 6 +-
.../component/test_vpc_vms_deployment.py | 6 +-
test/integration/component/test_vpn_users.py | 6 +-
test/integration/smoke/test_affinity_groups.py | 6 +-
test/integration/smoke/test_deploy_vm.py | 6 +-
.../smoke/test_deploy_vm_with_userdata.py | 6 +-
...deploy_vms_with_varied_deploymentplanners.py | 6 +-
test/integration/smoke/test_disk_offerings.py | 6 +-
test/integration/smoke/test_global_settings.py | 6 +-
test/integration/smoke/test_guest_vlan_range.py | 6 +-
test/integration/smoke/test_hosts.py | 6 +-
test/integration/smoke/test_internal_lb.py | 6 +-
test/integration/smoke/test_iso.py | 6 +-
test/integration/smoke/test_loadbalance.py | 6 +-
.../smoke/test_multipleips_per_nic.py | 6 +-
test/integration/smoke/test_network.py | 6 +-
test/integration/smoke/test_network_acl.py | 6 +-
test/integration/smoke/test_nic.py | 6 +-
.../smoke/test_non_contigiousvlan.py | 4 +-
.../integration/smoke/test_portable_publicip.py | 6 +-
test/integration/smoke/test_primary_storage.py | 6 +-
test/integration/smoke/test_privategw_acl.py | 6 +-
test/integration/smoke/test_public_ip_range.py | 6 +-
test/integration/smoke/test_pvlan.py | 6 +-
test/integration/smoke/test_regions.py | 6 +-
.../smoke/test_reset_vm_on_reboot.py | 6 +-
test/integration/smoke/test_resource_detail.py | 6 +-
test/integration/smoke/test_routers.py | 6 +-
test/integration/smoke/test_scale_vm.py | 6 +-
.../integration/smoke/test_secondary_storage.py | 6 +-
.../integration/smoke/test_service_offerings.py | 6 +-
test/integration/smoke/test_snapshots.py | 6 +-
test/integration/smoke/test_ssvm.py | 6 +-
test/integration/smoke/test_templates.py | 6 +-
test/integration/smoke/test_vm_life_cycle.py | 6 +-
test/integration/smoke/test_vm_snapshots.py | 6 +-
test/integration/smoke/test_volumes.py | 8 +-
test/integration/smoke/test_vpc_vpn.py | 6 +-
tools/marvin/marvin/cloudstackConnection.py | 68 +-
tools/marvin/marvin/cloudstackTestCase.py | 2 +-
tools/marvin/marvin/cloudstackTestClient.py | 5 +-
tools/marvin/marvin/integration/__init__.py | 18 -
tools/marvin/marvin/integration/lib/__init__.py | 16 -
tools/marvin/marvin/integration/lib/base.py | 3625 ------------------
tools/marvin/marvin/integration/lib/common.py | 955 -----
tools/marvin/marvin/integration/lib/utils.py | 472 ---
tools/marvin/marvin/lib/__init__.py | 16 +
tools/marvin/marvin/lib/base.py | 3625 ++++++++++++++++++
tools/marvin/marvin/lib/common.py | 955 +++++
tools/marvin/marvin/lib/utils.py | 472 +++
tools/marvin/setup.py | 4 +-
135 files changed, 5482 insertions(+), 5485 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/api/test/integration/api/test/account/testCreateAccount.py
----------------------------------------------------------------------
diff --git a/api/test/integration/api/test/account/testCreateAccount.py b/api/test/integration/api/test/account/testCreateAccount.py
index b094e81..52f2128 100644
--- a/api/test/integration/api/test/account/testCreateAccount.py
+++ b/api/test/integration/api/test/account/testCreateAccount.py
@@ -18,8 +18,8 @@
import factory
import marvin
from marvin import cloudstackTestCase
-from marvin.integration.lib.base import *
-from marvin.integration.lib import utils
+from marvin.lib.base import *
+from marvin.lib import utils
class AccountFactory(factory.Factory):
FACTORY_FOR = createAccount.createAccountCmd
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/component/maint/test_egress_rules_host_maintenance.py
----------------------------------------------------------------------
diff --git a/test/integration/component/maint/test_egress_rules_host_maintenance.py b/test/integration/component/maint/test_egress_rules_host_maintenance.py
index 2b81787..55d6125 100644
--- a/test/integration/component/maint/test_egress_rules_host_maintenance.py
+++ b/test/integration/component/maint/test_egress_rules_host_maintenance.py
@@ -23,9 +23,9 @@ from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
from marvin.sshClient import SshClient
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
#Import System modules
import time
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/component/maint/test_high_availability.py
----------------------------------------------------------------------
diff --git a/test/integration/component/maint/test_high_availability.py b/test/integration/component/maint/test_high_availability.py
index 6ada659..55cd293 100644
--- a/test/integration/component/maint/test_high_availability.py
+++ b/test/integration/component/maint/test_high_availability.py
@@ -23,9 +23,9 @@ import marvin
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from marvin.sshClient import SshClient
import datetime
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/component/maint/test_host_high_availability.py
----------------------------------------------------------------------
diff --git a/test/integration/component/maint/test_host_high_availability.py b/test/integration/component/maint/test_host_high_availability.py
index b4c50c7..4f22887 100644
--- a/test/integration/component/maint/test_host_high_availability.py
+++ b/test/integration/component/maint/test_host_high_availability.py
@@ -21,9 +21,9 @@
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
class Services:
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/component/maint/test_multiple_ip_ranges.py
----------------------------------------------------------------------
diff --git a/test/integration/component/maint/test_multiple_ip_ranges.py b/test/integration/component/maint/test_multiple_ip_ranges.py
index dc8021b..cc89706 100644
--- a/test/integration/component/maint/test_multiple_ip_ranges.py
+++ b/test/integration/component/maint/test_multiple_ip_ranges.py
@@ -19,9 +19,9 @@
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
from marvin.cloudstackException import cloudstackAPIException
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
# from netaddr import *
import netaddr
from nose.plugins.attrib import attr
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/component/maint/test_redundant_router.py
----------------------------------------------------------------------
diff --git a/test/integration/component/maint/test_redundant_router.py b/test/integration/component/maint/test_redundant_router.py
index 617a546..e282272 100644
--- a/test/integration/component/maint/test_redundant_router.py
+++ b/test/integration/component/maint/test_redundant_router.py
@@ -16,9 +16,9 @@
# under the License.
from nose.plugins.attrib import attr
-from marvin.integration.lib.base import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.common import *
+from marvin.lib.base import *
+from marvin.lib.utils import *
+from marvin.lib.common import *
#Import Local Modules
from marvin.cloudstackTestCase import cloudstackTestCase
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/component/maint/test_redundant_router_deployment_planning.py
----------------------------------------------------------------------
diff --git a/test/integration/component/maint/test_redundant_router_deployment_planning.py b/test/integration/component/maint/test_redundant_router_deployment_planning.py
index 879a4da..2801b39 100644
--- a/test/integration/component/maint/test_redundant_router_deployment_planning.py
+++ b/test/integration/component/maint/test_redundant_router_deployment_planning.py
@@ -16,9 +16,9 @@
# under the License.
from nose.plugins.attrib import attr
-from marvin.integration.lib.base import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.common import *
+from marvin.lib.base import *
+from marvin.lib.utils import *
+from marvin.lib.common import *
#Import Local Modules
from marvin.cloudstackTestCase import cloudstackTestCase
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/component/maint/test_redundant_router_network_rules.py
----------------------------------------------------------------------
diff --git a/test/integration/component/maint/test_redundant_router_network_rules.py b/test/integration/component/maint/test_redundant_router_network_rules.py
index 010aaaa..f49a118 100644
--- a/test/integration/component/maint/test_redundant_router_network_rules.py
+++ b/test/integration/component/maint/test_redundant_router_network_rules.py
@@ -16,9 +16,9 @@
# under the License.
from nose.plugins.attrib import attr
-from marvin.integration.lib.base import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.common import *
+from marvin.lib.base import *
+from marvin.lib.utils import *
+from marvin.lib.common import *
#Import Local Modules
from marvin.cloudstackTestCase import cloudstackTestCase
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/component/maint/test_vpc_host_maintenance.py
----------------------------------------------------------------------
diff --git a/test/integration/component/maint/test_vpc_host_maintenance.py b/test/integration/component/maint/test_vpc_host_maintenance.py
index 57dfb4b..5c18de8 100644
--- a/test/integration/component/maint/test_vpc_host_maintenance.py
+++ b/test/integration/component/maint/test_vpc_host_maintenance.py
@@ -22,9 +22,9 @@ import marvin
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from marvin.sshClient import SshClient
import datetime
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/component/maint/test_vpc_on_host_maintenance.py
----------------------------------------------------------------------
diff --git a/test/integration/component/maint/test_vpc_on_host_maintenance.py b/test/integration/component/maint/test_vpc_on_host_maintenance.py
index 6630ee6..3a2f7f5 100644
--- a/test/integration/component/maint/test_vpc_on_host_maintenance.py
+++ b/test/integration/component/maint/test_vpc_on_host_maintenance.py
@@ -18,9 +18,9 @@
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
class Services:
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/component/test_accounts.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_accounts.py b/test/integration/component/test_accounts.py
index 650a595..45df911 100644
--- a/test/integration/component/test_accounts.py
+++ b/test/integration/component/test_accounts.py
@@ -19,9 +19,9 @@
#Import Local Modules
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from marvin.sshClient import SshClient
from nose.plugins.attrib import attr
from marvin.cloudstackException import cloudstackAPIException
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/component/test_add_remove_network.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_add_remove_network.py b/test/integration/component/test_add_remove_network.py
index 67ab24a..b96d8d3 100644
--- a/test/integration/component/test_add_remove_network.py
+++ b/test/integration/component/test_add_remove_network.py
@@ -29,7 +29,7 @@
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import cloudstackTestCase, unittest
from ddt import ddt, data
-from marvin.integration.lib.base import (
+from marvin.lib.base import (
Account,
Domain,
ServiceOffering,
@@ -39,7 +39,7 @@ from marvin.integration.lib.base import (
VpcOffering,
VPC
)
-from marvin.integration.lib.common import (get_domain,
+from marvin.lib.common import (get_domain,
get_zone,
get_template,
list_virtual_machines,
@@ -49,7 +49,7 @@ from marvin.integration.lib.common import (get_domain,
update_resource_limit
)
-from marvin.integration.lib.utils import (validateList,
+from marvin.lib.utils import (validateList,
random_gen,
get_hypervisor_type,
cleanup_resources)
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/component/test_advancedsg_networks.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_advancedsg_networks.py b/test/integration/component/test_advancedsg_networks.py
index 207659f..d2ea499 100644
--- a/test/integration/component/test_advancedsg_networks.py
+++ b/test/integration/component/test_advancedsg_networks.py
@@ -19,7 +19,7 @@
"""
from marvin.cloudstackTestCase import cloudstackTestCase, unittest
from ddt import ddt, data
-from marvin.integration.lib.base import (Zone,
+from marvin.lib.base import (Zone,
ServiceOffering,
Account,
NetworkOffering,
@@ -31,14 +31,14 @@ from marvin.integration.lib.base import (Zone,
SecurityGroup,
Host)
-from marvin.integration.lib.common import (get_domain,
+from marvin.lib.common import (get_domain,
get_zone,
get_template,
get_free_vlan,
list_virtual_machines,
wait_for_cleanup)
-from marvin.integration.lib.utils import (cleanup_resources,
+from marvin.lib.utils import (cleanup_resources,
random_gen,
validateList)
from marvin.cloudstackAPI import (authorizeSecurityGroupIngress,
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/component/test_affinity_groups.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_affinity_groups.py b/test/integration/component/test_affinity_groups.py
index 4fdb8f6..e5d8028 100644
--- a/test/integration/component/test_affinity_groups.py
+++ b/test/integration/component/test_affinity_groups.py
@@ -17,9 +17,9 @@
# under the License.
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from marvin.sshClient import SshClient
from nose.plugins.attrib import attr
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/component/test_allocation_states.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_allocation_states.py b/test/integration/component/test_allocation_states.py
index 5ce0b21..2da0f7b 100644
--- a/test/integration/component/test_allocation_states.py
+++ b/test/integration/component/test_allocation_states.py
@@ -19,9 +19,9 @@ import marvin
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from nose.plugins.attrib import attr
import datetime
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/component/test_asa1000v_fw.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_asa1000v_fw.py b/test/integration/component/test_asa1000v_fw.py
index c8a11ab..e913c76 100644
--- a/test/integration/component/test_asa1000v_fw.py
+++ b/test/integration/component/test_asa1000v_fw.py
@@ -22,9 +22,9 @@ import marvin
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from marvin.sshClient import SshClient
import datetime
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/component/test_assign_vm.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_assign_vm.py b/test/integration/component/test_assign_vm.py
index 400d5f2..5de8dad 100644
--- a/test/integration/component/test_assign_vm.py
+++ b/test/integration/component/test_assign_vm.py
@@ -20,7 +20,7 @@
#Import Local Modules
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import cloudstackTestCase
-from marvin.integration.lib.base import (Account,
+from marvin.lib.base import (Account,
Domain,
User,
Project,
@@ -29,7 +29,7 @@ from marvin.integration.lib.base import (Account,
DiskOffering,
ServiceOffering,
VirtualMachine)
-from marvin.integration.lib.common import (get_domain,
+from marvin.lib.common import (get_domain,
get_zone,
get_template,
list_volumes,
@@ -37,7 +37,7 @@ from marvin.integration.lib.common import (get_domain,
list_networks,
list_snapshots,
list_virtual_machines)
-from marvin.integration.lib.utils import cleanup_resources
+from marvin.lib.utils import cleanup_resources
def log_test_exceptions(func):
def test_wrap_exception_log(self, *args, **kwargs):
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/component/test_baremetal.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_baremetal.py b/test/integration/component/test_baremetal.py
index 2439d0d..886b18c 100644
--- a/test/integration/component/test_baremetal.py
+++ b/test/integration/component/test_baremetal.py
@@ -21,9 +21,9 @@ import marvin
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
from marvin.sshClient import SshClient
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from nose.plugins.attrib import attr
import telnetlib
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/component/test_base_image_updation.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_base_image_updation.py b/test/integration/component/test_base_image_updation.py
index af968cc..2d6c83b 100644
--- a/test/integration/component/test_base_image_updation.py
+++ b/test/integration/component/test_base_image_updation.py
@@ -31,7 +31,7 @@ from marvin.codes import (PASS,
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import cloudstackTestCase, unittest
-from marvin.integration.lib.base import (ServiceOffering,
+from marvin.lib.base import (ServiceOffering,
Account,
VirtualMachine,
Volume,
@@ -41,13 +41,13 @@ from marvin.integration.lib.base import (ServiceOffering,
Template
)
-from marvin.integration.lib.common import (get_domain,
+from marvin.lib.common import (get_domain,
get_zone,
get_template,
list_templates
)
-from marvin.integration.lib.utils import (validateList,
+from marvin.lib.utils import (validateList,
cleanup_resources)
import time
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/component/test_blocker_bugs.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_blocker_bugs.py b/test/integration/component/test_blocker_bugs.py
index 04a2656..1ecbc77 100644
--- a/test/integration/component/test_blocker_bugs.py
+++ b/test/integration/component/test_blocker_bugs.py
@@ -18,9 +18,9 @@
"""
import marvin
from nose.plugins.attrib import attr
-from marvin.integration.lib.base import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.common import *
+from marvin.lib.base import *
+from marvin.lib.utils import *
+from marvin.lib.common import *
#Import Local Modules
from marvin.cloudstackTestCase import *
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/component/test_cpu_domain_limits.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_cpu_domain_limits.py b/test/integration/component/test_cpu_domain_limits.py
index cd2ab54..3828d05 100644
--- a/test/integration/component/test_cpu_domain_limits.py
+++ b/test/integration/component/test_cpu_domain_limits.py
@@ -20,20 +20,20 @@
# Import Local Modules
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import cloudstackTestCase, unittest
-from marvin.integration.lib.base import (
+from marvin.lib.base import (
Account,
ServiceOffering,
VirtualMachine,
Resources,
Domain
)
-from marvin.integration.lib.common import (get_domain,
+from marvin.lib.common import (get_domain,
get_zone,
get_template,
find_suitable_host,
get_resource_type
)
-from marvin.integration.lib.utils import cleanup_resources
+from marvin.lib.utils import cleanup_resources
class Services:
"""Test resource limit services
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/component/test_cpu_limits.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_cpu_limits.py b/test/integration/component/test_cpu_limits.py
index c6d8d14..4776519 100644
--- a/test/integration/component/test_cpu_limits.py
+++ b/test/integration/component/test_cpu_limits.py
@@ -20,20 +20,20 @@
# Import Local Modules
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import cloudstackTestCase, unittest
-from marvin.integration.lib.base import (
+from marvin.lib.base import (
Account,
ServiceOffering,
VirtualMachine,
Domain,
Resources
)
-from marvin.integration.lib.common import (get_domain,
+from marvin.lib.common import (get_domain,
get_zone,
get_template,
find_suitable_host,
get_resource_type
)
-from marvin.integration.lib.utils import cleanup_resources
+from marvin.lib.utils import cleanup_resources
class Services:
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/component/test_cpu_max_limits.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_cpu_max_limits.py b/test/integration/component/test_cpu_max_limits.py
index afbfcb4..a6ab7a6 100644
--- a/test/integration/component/test_cpu_max_limits.py
+++ b/test/integration/component/test_cpu_max_limits.py
@@ -20,7 +20,7 @@
# Import Local Modules
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import cloudstackTestCase, unittest
-from marvin.integration.lib.base import (
+from marvin.lib.base import (
Account,
ServiceOffering,
VirtualMachine,
@@ -28,11 +28,11 @@ from marvin.integration.lib.base import (
Domain,
Project
)
-from marvin.integration.lib.common import (get_domain,
+from marvin.lib.common import (get_domain,
get_zone,
get_template
)
-from marvin.integration.lib.utils import cleanup_resources
+from marvin.lib.utils import cleanup_resources
class Services:
"""Test resource limit services
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/component/test_cpu_project_limits.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_cpu_project_limits.py b/test/integration/component/test_cpu_project_limits.py
index a81c70a..ccfa691 100644
--- a/test/integration/component/test_cpu_project_limits.py
+++ b/test/integration/component/test_cpu_project_limits.py
@@ -20,20 +20,20 @@
# Import Local Modules
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import cloudstackTestCase, unittest
-from marvin.integration.lib.base import (
+from marvin.lib.base import (
Account,
ServiceOffering,
VirtualMachine,
Domain,
Project
)
-from marvin.integration.lib.common import (get_domain,
+from marvin.lib.common import (get_domain,
get_zone,
get_template,
find_suitable_host,
get_resource_type
)
-from marvin.integration.lib.utils import cleanup_resources
+from marvin.lib.utils import cleanup_resources
class Services:
"""Test resource limit services
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/component/test_custom_hostname.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_custom_hostname.py b/test/integration/component/test_custom_hostname.py
index 1549a20..74da3d6 100644
--- a/test/integration/component/test_custom_hostname.py
+++ b/test/integration/component/test_custom_hostname.py
@@ -20,9 +20,9 @@
import marvin
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
class Services:
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/component/test_deploy_vm_userdata_reg.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_deploy_vm_userdata_reg.py b/test/integration/component/test_deploy_vm_userdata_reg.py
index b282a86..fa0a88c 100755
--- a/test/integration/component/test_deploy_vm_userdata_reg.py
+++ b/test/integration/component/test_deploy_vm_userdata_reg.py
@@ -19,9 +19,9 @@
# this script will cover VMdeployment with Userdata tests
from marvin.cloudstackTestCase import cloudstackTestCase
-from marvin.integration.lib.base import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.common import *
+from marvin.lib.base import *
+from marvin.lib.utils import *
+from marvin.lib.common import *
from nose.plugins.attrib import attr
from marvin.sshClient import SshClient
import unittest
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/component/test_egress_fw_rules.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_egress_fw_rules.py b/test/integration/component/test_egress_fw_rules.py
index 8fa8a5e..06203e0 100644
--- a/test/integration/component/test_egress_fw_rules.py
+++ b/test/integration/component/test_egress_fw_rules.py
@@ -21,7 +21,7 @@
import unittest
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import cloudstackTestCase
-from marvin.integration.lib.base import (Account,
+from marvin.lib.base import (Account,
Domain,
Router,
Network,
@@ -31,14 +31,14 @@ from marvin.integration.lib.base import (Account,
FireWallRule,
NATRule,
PublicIPAddress)
-from marvin.integration.lib.common import (get_domain,
+from marvin.lib.common import (get_domain,
get_zone,
get_template,
list_routers,
wait_for_cleanup,
list_virtual_machines
)
-from marvin.integration.lib.utils import cleanup_resources, validateList
+from marvin.lib.utils import cleanup_resources, validateList
from marvin.cloudstackAPI import rebootRouter
from marvin.cloudstackAPI.createEgressFirewallRule import createEgressFirewallRuleCmd
from marvin.cloudstackAPI.deleteEgressFirewallRule import deleteEgressFirewallRuleCmd
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/component/test_egress_rules.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_egress_rules.py b/test/integration/component/test_egress_rules.py
index a2443d4..7760ee1 100644
--- a/test/integration/component/test_egress_rules.py
+++ b/test/integration/component/test_egress_rules.py
@@ -20,13 +20,13 @@
#Import Local Modules
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import cloudstackTestCase
-from marvin.integration.lib.utils import (random_gen,
+from marvin.lib.utils import (random_gen,
cleanup_resources)
-from marvin.integration.lib.base import (SecurityGroup,
+from marvin.lib.base import (SecurityGroup,
VirtualMachine,
Account,
ServiceOffering)
-from marvin.integration.lib.common import (get_domain,
+from marvin.lib.common import (get_domain,
get_zone,
get_template,
list_virtual_machines)
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/component/test_eip_elb.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_eip_elb.py b/test/integration/component/test_eip_elb.py
index d639d82..69af404 100644
--- a/test/integration/component/test_eip_elb.py
+++ b/test/integration/component/test_eip_elb.py
@@ -22,9 +22,9 @@ import marvin
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from marvin.sshClient import SshClient
import datetime
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/component/test_explicit_dedication.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_explicit_dedication.py b/test/integration/component/test_explicit_dedication.py
index 7aefc21..cf7e3d0 100644
--- a/test/integration/component/test_explicit_dedication.py
+++ b/test/integration/component/test_explicit_dedication.py
@@ -21,9 +21,9 @@ import marvin
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
from marvin.sshClient import SshClient
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from nose.plugins.attrib import attr
#Import System modules
import time
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/component/test_haproxy.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_haproxy.py b/test/integration/component/test_haproxy.py
index f77e4ec..750c300 100644
--- a/test/integration/component/test_haproxy.py
+++ b/test/integration/component/test_haproxy.py
@@ -19,7 +19,7 @@
# Import Local Modules
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import cloudstackTestCase
-from marvin.integration.lib.base import (
+from marvin.lib.base import (
Account,
ServiceOffering,
VirtualMachine,
@@ -31,11 +31,11 @@ from marvin.integration.lib.base import (
Vpn,
NATRule
)
-from marvin.integration.lib.common import (get_domain,
+from marvin.lib.common import (get_domain,
get_zone,
get_template
)
-from marvin.integration.lib.utils import (cleanup_resources,
+from marvin.lib.utils import (cleanup_resources,
random_gen)
from marvin.cloudstackAPI import createLBStickinessPolicy
from marvin.sshClient import SshClient
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/component/test_implicit_planner.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_implicit_planner.py b/test/integration/component/test_implicit_planner.py
index 2b656d9..a44026a 100644
--- a/test/integration/component/test_implicit_planner.py
+++ b/test/integration/component/test_implicit_planner.py
@@ -21,9 +21,9 @@ import marvin
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
from marvin.sshClient import SshClient
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from nose.plugins.attrib import attr
#Import System modules
import time
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/component/test_ip_reservation.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_ip_reservation.py b/test/integration/component/test_ip_reservation.py
index 224212f..ae8d701 100755
--- a/test/integration/component/test_ip_reservation.py
+++ b/test/integration/component/test_ip_reservation.py
@@ -20,9 +20,9 @@ import marvin
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
from marvin.cloudstackException import cloudstackAPIException
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
import netaddr
from nose.plugins.attrib import attr
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/component/test_ldap.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_ldap.py b/test/integration/component/test_ldap.py
index d9e7c35..b66a09e 100644
--- a/test/integration/component/test_ldap.py
+++ b/test/integration/component/test_ldap.py
@@ -29,9 +29,9 @@ import hashlib
import random
from marvin.cloudstackAPI import *
from marvin.cloudstackAPI import login
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from nose.plugins.attrib import attr
import urllib
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/component/test_memory_limits.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_memory_limits.py b/test/integration/component/test_memory_limits.py
index 84af4b1..dacd8cf 100644
--- a/test/integration/component/test_memory_limits.py
+++ b/test/integration/component/test_memory_limits.py
@@ -19,21 +19,21 @@
# Import Local Modules
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import cloudstackTestCase, unittest
-from marvin.integration.lib.base import (
+from marvin.lib.base import (
Account,
ServiceOffering,
VirtualMachine,
Resources,
Domain
)
-from marvin.integration.lib.common import (get_domain,
+from marvin.lib.common import (get_domain,
get_zone,
get_template,
wait_for_cleanup,
find_suitable_host,
get_resource_type
)
-from marvin.integration.lib.utils import cleanup_resources
+from marvin.lib.utils import cleanup_resources
class Services:
"""Test memory resource limit services
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/component/test_mm_domain_limits.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_mm_domain_limits.py b/test/integration/component/test_mm_domain_limits.py
index a6c4de8..dbb8737 100644
--- a/test/integration/component/test_mm_domain_limits.py
+++ b/test/integration/component/test_mm_domain_limits.py
@@ -19,14 +19,14 @@
# Import Local Modules
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import cloudstackTestCase, unittest
-from marvin.integration.lib.base import (
+from marvin.lib.base import (
Account,
ServiceOffering,
VirtualMachine,
Resources,
Domain
)
-from marvin.integration.lib.common import (get_domain,
+from marvin.lib.common import (get_domain,
get_zone,
get_template,
wait_for_cleanup,
@@ -34,7 +34,7 @@ from marvin.integration.lib.common import (get_domain,
get_resource_type,
update_resource_count
)
-from marvin.integration.lib.utils import cleanup_resources
+from marvin.lib.utils import cleanup_resources
class Services:
"""Test memory resource limit services
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/component/test_mm_max_limits.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_mm_max_limits.py b/test/integration/component/test_mm_max_limits.py
index df29ea9..bb5e2f1 100644
--- a/test/integration/component/test_mm_max_limits.py
+++ b/test/integration/component/test_mm_max_limits.py
@@ -19,7 +19,7 @@
# Import Local Modules
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import cloudstackTestCase, unittest
-from marvin.integration.lib.base import (
+from marvin.lib.base import (
Account,
ServiceOffering,
VirtualMachine,
@@ -27,11 +27,11 @@ from marvin.integration.lib.base import (
Domain,
Project
)
-from marvin.integration.lib.common import (get_domain,
+from marvin.lib.common import (get_domain,
get_zone,
get_template
)
-from marvin.integration.lib.utils import cleanup_resources
+from marvin.lib.utils import cleanup_resources
class Services:
"""Test memory resource limit services
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/component/test_mm_project_limits.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_mm_project_limits.py b/test/integration/component/test_mm_project_limits.py
index d030692..039ae1e 100644
--- a/test/integration/component/test_mm_project_limits.py
+++ b/test/integration/component/test_mm_project_limits.py
@@ -19,21 +19,21 @@
# Import Local Modules
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import cloudstackTestCase, unittest
-from marvin.integration.lib.base import (
+from marvin.lib.base import (
Account,
ServiceOffering,
VirtualMachine,
Domain,
Project
)
-from marvin.integration.lib.common import (get_domain,
+from marvin.lib.common import (get_domain,
get_zone,
get_template,
wait_for_cleanup,
find_suitable_host,
get_resource_type
)
-from marvin.integration.lib.utils import cleanup_resources
+from marvin.lib.utils import cleanup_resources
class Services:
"""Test memory resource limit services
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/component/test_multiple_ip_ranges.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_multiple_ip_ranges.py b/test/integration/component/test_multiple_ip_ranges.py
index aae90c4..76dfdca 100644
--- a/test/integration/component/test_multiple_ip_ranges.py
+++ b/test/integration/component/test_multiple_ip_ranges.py
@@ -19,9 +19,9 @@
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
from marvin.cloudstackException import cloudstackAPIException
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from netaddr import *
from nose.plugins.attrib import attr
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/component/test_netscaler_configs.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_netscaler_configs.py b/test/integration/component/test_netscaler_configs.py
index 98c4748..5d87ca5 100644
--- a/test/integration/component/test_netscaler_configs.py
+++ b/test/integration/component/test_netscaler_configs.py
@@ -22,9 +22,9 @@ import marvin
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from marvin.sshClient import SshClient
import datetime
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/component/test_netscaler_lb.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_netscaler_lb.py b/test/integration/component/test_netscaler_lb.py
index 26df545..46c092e 100644
--- a/test/integration/component/test_netscaler_lb.py
+++ b/test/integration/component/test_netscaler_lb.py
@@ -22,9 +22,9 @@ import marvin
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from marvin.sshClient import SshClient
import datetime
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/component/test_netscaler_lb_algo.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_netscaler_lb_algo.py b/test/integration/component/test_netscaler_lb_algo.py
index 3c18fcd..db5db79 100644
--- a/test/integration/component/test_netscaler_lb_algo.py
+++ b/test/integration/component/test_netscaler_lb_algo.py
@@ -22,9 +22,9 @@ import marvin
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from marvin.sshClient import SshClient
import datetime
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/component/test_netscaler_lb_sticky.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_netscaler_lb_sticky.py b/test/integration/component/test_netscaler_lb_sticky.py
index 6c27a08..391ccaf 100644
--- a/test/integration/component/test_netscaler_lb_sticky.py
+++ b/test/integration/component/test_netscaler_lb_sticky.py
@@ -22,9 +22,9 @@ import marvin
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from marvin.sshClient import SshClient
import datetime
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/component/test_netscaler_nw_off.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_netscaler_nw_off.py b/test/integration/component/test_netscaler_nw_off.py
index 3372612..cc5e3a3 100644
--- a/test/integration/component/test_netscaler_nw_off.py
+++ b/test/integration/component/test_netscaler_nw_off.py
@@ -22,9 +22,9 @@ import marvin
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from marvin.sshClient import SshClient
import datetime
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/component/test_network_offering.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_network_offering.py b/test/integration/component/test_network_offering.py
index 33c4305..e587cdd 100644
--- a/test/integration/component/test_network_offering.py
+++ b/test/integration/component/test_network_offering.py
@@ -22,9 +22,9 @@ import marvin
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
import datetime
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/component/test_non_contiguous_vlan.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_non_contiguous_vlan.py b/test/integration/component/test_non_contiguous_vlan.py
index 3ebaf3a..b178d84 100644
--- a/test/integration/component/test_non_contiguous_vlan.py
+++ b/test/integration/component/test_non_contiguous_vlan.py
@@ -28,17 +28,17 @@
from marvin.cloudstackTestCase import (cloudstackTestCase,unittest)
-from marvin.integration.lib.base import (Account,
+from marvin.lib.base import (Account,
ServiceOffering,
PhysicalNetwork,
VirtualMachine,
)
-from marvin.integration.lib.common import (get_zone,
+from marvin.lib.common import (get_zone,
get_pod,
get_domain,
get_template,
setNonContiguousVlanIds)
-from marvin.integration.lib.utils import (cleanup_resources,
+from marvin.lib.utils import (cleanup_resources,
xsplit)
from nose.plugins.attrib import attr
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/component/test_persistent_networks.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_persistent_networks.py b/test/integration/component/test_persistent_networks.py
index f61ccaa..2439983 100644
--- a/test/integration/component/test_persistent_networks.py
+++ b/test/integration/component/test_persistent_networks.py
@@ -20,9 +20,9 @@ import marvin
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
from marvin.cloudstackException import cloudstackAPIException
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
import netaddr
from nose.plugins.attrib import attr
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/component/test_portable_ip.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_portable_ip.py b/test/integration/component/test_portable_ip.py
index 8c65214..04e1bdb 100644
--- a/test/integration/component/test_portable_ip.py
+++ b/test/integration/component/test_portable_ip.py
@@ -19,9 +19,9 @@
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
from marvin.cloudstackException import cloudstackAPIException
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from netaddr import *
from marvin.sshClient import SshClient
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/component/test_project_configs.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_project_configs.py b/test/integration/component/test_project_configs.py
index be6cf1c..bd11e60 100644
--- a/test/integration/component/test_project_configs.py
+++ b/test/integration/component/test_project_configs.py
@@ -21,9 +21,9 @@ import marvin
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from marvin.sshClient import SshClient
import datetime
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/component/test_project_limits.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_project_limits.py b/test/integration/component/test_project_limits.py
index 7cb29b7..3e663f8 100644
--- a/test/integration/component/test_project_limits.py
+++ b/test/integration/component/test_project_limits.py
@@ -21,9 +21,9 @@ import marvin
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from marvin.codes import PASS
import datetime
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/component/test_project_resources.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_project_resources.py b/test/integration/component/test_project_resources.py
index d6a732d..9e6e2e1 100644
--- a/test/integration/component/test_project_resources.py
+++ b/test/integration/component/test_project_resources.py
@@ -19,7 +19,7 @@
#Import Local Modules
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import cloudstackTestCase, unittest
-from marvin.integration.lib.base import (VirtualMachine,
+from marvin.lib.base import (VirtualMachine,
Account,
Project,
NATRule,
@@ -35,7 +35,7 @@ from marvin.integration.lib.base import (VirtualMachine,
DiskOffering,
LoadBalancerRule)
-from marvin.integration.lib.common import (get_zone,
+from marvin.lib.common import (get_zone,
get_template,
get_domain,
list_volumes,
@@ -44,7 +44,7 @@ from marvin.integration.lib.common import (get_zone,
get_free_vlan,
wait_for_cleanup)
-from marvin.integration.lib.utils import cleanup_resources
+from marvin.lib.utils import cleanup_resources
import random
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/component/test_project_usage.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_project_usage.py b/test/integration/component/test_project_usage.py
index ba0a63c..5b6de23 100644
--- a/test/integration/component/test_project_usage.py
+++ b/test/integration/component/test_project_usage.py
@@ -21,9 +21,9 @@ import marvin
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from marvin.sshClient import SshClient
import datetime
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/component/test_projects.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_projects.py b/test/integration/component/test_projects.py
index 4b82fc2..c792f0c 100644
--- a/test/integration/component/test_projects.py
+++ b/test/integration/component/test_projects.py
@@ -21,9 +21,9 @@ import marvin
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from marvin.sshClient import SshClient
import datetime
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/component/test_recurring_snapshots.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_recurring_snapshots.py b/test/integration/component/test_recurring_snapshots.py
index 06df170..8cd9fde 100644
--- a/test/integration/component/test_recurring_snapshots.py
+++ b/test/integration/component/test_recurring_snapshots.py
@@ -18,9 +18,9 @@
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
class Services:
"""Test Snapshots Services
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/component/test_redundant_router_cleanups.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_redundant_router_cleanups.py b/test/integration/component/test_redundant_router_cleanups.py
index e30c102..9d77b96 100644
--- a/test/integration/component/test_redundant_router_cleanups.py
+++ b/test/integration/component/test_redundant_router_cleanups.py
@@ -16,9 +16,9 @@
# under the License.
from nose.plugins.attrib import attr
-from marvin.integration.lib.base import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.common import *
+from marvin.lib.base import *
+from marvin.lib.utils import *
+from marvin.lib.common import *
#Import Local Modules
from marvin.cloudstackTestCase import cloudstackTestCase
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/component/test_redundant_router_services.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_redundant_router_services.py b/test/integration/component/test_redundant_router_services.py
index 64bb6e9..bcbe227 100644
--- a/test/integration/component/test_redundant_router_services.py
+++ b/test/integration/component/test_redundant_router_services.py
@@ -17,9 +17,9 @@
from nose.plugins.attrib import attr
-from marvin.integration.lib.base import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.common import *
+from marvin.lib.base import *
+from marvin.lib.utils import *
+from marvin.lib.common import *
#Import Local Modules
from marvin.cloudstackTestCase import cloudstackTestCase
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/component/test_redundant_router_upgrades.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_redundant_router_upgrades.py b/test/integration/component/test_redundant_router_upgrades.py
index e9303c0..c2b356c 100644
--- a/test/integration/component/test_redundant_router_upgrades.py
+++ b/test/integration/component/test_redundant_router_upgrades.py
@@ -17,9 +17,9 @@
from nose.plugins.attrib import attr
-from marvin.integration.lib.base import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.common import *
+from marvin.lib.base import *
+from marvin.lib.utils import *
+from marvin.lib.common import *
#Import Local Modules
from marvin.cloudstackTestCase import cloudstackTestCase
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/component/test_regions.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_regions.py b/test/integration/component/test_regions.py
index 252ba70..2418597 100644
--- a/test/integration/component/test_regions.py
+++ b/test/integration/component/test_regions.py
@@ -17,9 +17,9 @@
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from nose.plugins.attrib import attr
from random import choice
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/component/test_regions_accounts.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_regions_accounts.py b/test/integration/component/test_regions_accounts.py
index 886e620..0057235 100644
--- a/test/integration/component/test_regions_accounts.py
+++ b/test/integration/component/test_regions_accounts.py
@@ -17,9 +17,9 @@
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from nose.plugins.attrib import attr
class Services:
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/component/test_reset_ssh_keypair.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_reset_ssh_keypair.py b/test/integration/component/test_reset_ssh_keypair.py
index ded2529..684cb47 100644
--- a/test/integration/component/test_reset_ssh_keypair.py
+++ b/test/integration/component/test_reset_ssh_keypair.py
@@ -19,18 +19,18 @@
"""
#Import Local Modules
-from marvin.integration.lib.base import (VirtualMachine,
+from marvin.lib.base import (VirtualMachine,
SSHKeyPair,
Account,
Template,
ServiceOffering,
EgressFireWallRule)
-from marvin.integration.lib.common import (get_domain,
+from marvin.lib.common import (get_domain,
get_zone,
get_template,
list_virtual_machines,
list_volumes)
-from marvin.integration.lib.utils import (cleanup_resources,
+from marvin.lib.utils import (cleanup_resources,
random_gen,
validateList)
from marvin.cloudstackTestCase import cloudstackTestCase, unittest
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/component/test_resource_limits.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_resource_limits.py b/test/integration/component/test_resource_limits.py
index f0d558e..8da071d 100644
--- a/test/integration/component/test_resource_limits.py
+++ b/test/integration/component/test_resource_limits.py
@@ -19,7 +19,7 @@
#Import Local Modules
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import cloudstackTestCase
-from marvin.integration.lib.base import (VirtualMachine,
+from marvin.lib.base import (VirtualMachine,
Snapshot,
Template,
PublicIPAddress,
@@ -31,14 +31,14 @@ from marvin.integration.lib.base import (VirtualMachine,
NetworkOffering,
ServiceOffering,
Configurations)
-from marvin.integration.lib.common import (list_volumes,
+from marvin.lib.common import (list_volumes,
get_domain,
get_zone,
get_template,
update_resource_limit,
list_configurations,
wait_for_cleanup)
-from marvin.integration.lib.utils import cleanup_resources
+from marvin.lib.utils import cleanup_resources
import time
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/component/test_routers.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_routers.py b/test/integration/component/test_routers.py
index f8359f0..368db60 100644
--- a/test/integration/component/test_routers.py
+++ b/test/integration/component/test_routers.py
@@ -21,9 +21,9 @@ import marvin
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
#Import System modules
import time
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/component/test_security_groups.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_security_groups.py b/test/integration/component/test_security_groups.py
index 8e07396..76765d0 100644
--- a/test/integration/component/test_security_groups.py
+++ b/test/integration/component/test_security_groups.py
@@ -22,9 +22,9 @@ import marvin
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from marvin.sshClient import SshClient
#Import System modules
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/component/test_shared_networks.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_shared_networks.py b/test/integration/component/test_shared_networks.py
index 99cce19..2623f75 100644
--- a/test/integration/component/test_shared_networks.py
+++ b/test/integration/component/test_shared_networks.py
@@ -20,7 +20,7 @@
#Import Local Modules
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import cloudstackTestCase, unittest
-from marvin.integration.lib.base import (Account,
+from marvin.lib.base import (Account,
Network,
NetworkOffering,
VirtualMachine,
@@ -31,9 +31,9 @@ from marvin.integration.lib.base import (Account,
FireWallRule,
ServiceOffering,
PublicIPAddress)
-from marvin.integration.lib.utils import (cleanup_resources,
+from marvin.lib.utils import (cleanup_resources,
xsplit)
-from marvin.integration.lib.common import (get_domain,
+from marvin.lib.common import (get_domain,
get_zone,
get_template,
wait_for_cleanup,
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/component/test_snapshot_gc.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_snapshot_gc.py b/test/integration/component/test_snapshot_gc.py
index 1e1cc5d..32a4067 100644
--- a/test/integration/component/test_snapshot_gc.py
+++ b/test/integration/component/test_snapshot_gc.py
@@ -18,10 +18,10 @@
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
-from marvin.integration.lib.utils import is_snapshot_on_nfs
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
+from marvin.lib.utils import is_snapshot_on_nfs
class Services:
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/component/test_snapshot_limits.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_snapshot_limits.py b/test/integration/component/test_snapshot_limits.py
index a1bf1ba..180da44 100644
--- a/test/integration/component/test_snapshot_limits.py
+++ b/test/integration/component/test_snapshot_limits.py
@@ -18,10 +18,10 @@
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
-from marvin.integration.lib.utils import is_snapshot_on_nfs
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
+from marvin.lib.utils import is_snapshot_on_nfs
import os
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/component/test_snapshots.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_snapshots.py b/test/integration/component/test_snapshots.py
index 17579d6..06ea112 100644
--- a/test/integration/component/test_snapshots.py
+++ b/test/integration/component/test_snapshots.py
@@ -20,7 +20,7 @@
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import cloudstackTestCase, unittest
-from marvin.integration.lib.base import (Snapshot,
+from marvin.lib.base import (Snapshot,
Template,
VirtualMachine,
Account,
@@ -28,7 +28,7 @@ from marvin.integration.lib.base import (Snapshot,
DiskOffering,
Volume)
-from marvin.integration.lib.common import (get_domain,
+from marvin.lib.common import (get_domain,
get_zone,
get_template,
list_events,
@@ -38,7 +38,7 @@ from marvin.integration.lib.common import (get_domain,
list_virtual_machines,
)
-from marvin.integration.lib.utils import (cleanup_resources,
+from marvin.lib.utils import (cleanup_resources,
format_volume_to_ext3,
random_gen,
is_snapshot_on_nfs,
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/component/test_snapshots_improvement.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_snapshots_improvement.py b/test/integration/component/test_snapshots_improvement.py
index 77c240d..ac282d6 100644
--- a/test/integration/component/test_snapshots_improvement.py
+++ b/test/integration/component/test_snapshots_improvement.py
@@ -20,10 +20,10 @@
# Import Local Modules
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import cloudstackTestCase, unittest
-from marvin.integration.lib.utils import (random_gen,
+from marvin.lib.utils import (random_gen,
is_snapshot_on_nfs,
cleanup_resources)
-from marvin.integration.lib.base import (
+from marvin.lib.base import (
Account,
ServiceOffering,
VirtualMachine,
@@ -32,7 +32,7 @@ from marvin.integration.lib.base import (
Volume,
DiskOffering
)
-from marvin.integration.lib.common import (get_domain,
+from marvin.lib.common import (get_domain,
get_zone,
get_template,
list_snapshots
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/component/test_stopped_vm.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_stopped_vm.py b/test/integration/component/test_stopped_vm.py
index 4ba94bf..5f3cea2 100644
--- a/test/integration/component/test_stopped_vm.py
+++ b/test/integration/component/test_stopped_vm.py
@@ -22,9 +22,9 @@ import marvin
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
#Import System modules
import time
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/component/test_storage_motion.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_storage_motion.py b/test/integration/component/test_storage_motion.py
index 194ba97..22dd73a 100644
--- a/test/integration/component/test_storage_motion.py
+++ b/test/integration/component/test_storage_motion.py
@@ -20,9 +20,9 @@
import marvin
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from nose.plugins.attrib import attr
#Import System modules
import time
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/component/test_tags.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_tags.py b/test/integration/component/test_tags.py
index 2a6e076..834ec59 100644
--- a/test/integration/component/test_tags.py
+++ b/test/integration/component/test_tags.py
@@ -21,9 +21,9 @@ import marvin
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
import datetime
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/component/test_templates.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_templates.py b/test/integration/component/test_templates.py
index 3e83615..6babe7e 100644
--- a/test/integration/component/test_templates.py
+++ b/test/integration/component/test_templates.py
@@ -21,9 +21,9 @@ import marvin
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
import urllib
from random import random
#Import System modules
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/component/test_update_vm.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_update_vm.py b/test/integration/component/test_update_vm.py
index 0786310..fdb0ab8 100644
--- a/test/integration/component/test_update_vm.py
+++ b/test/integration/component/test_update_vm.py
@@ -17,9 +17,9 @@
from marvin.cloudstackTestCase import cloudstackTestCase
-from marvin.integration.lib.base import Account, VirtualMachine, ServiceOffering
-from marvin.integration.lib.utils import cleanup_resources
-from marvin.integration.lib.common import get_zone, get_domain, get_template
+from marvin.lib.base import Account, VirtualMachine, ServiceOffering
+from marvin.lib.utils import cleanup_resources
+from marvin.lib.common import get_zone, get_domain, get_template
from nose.plugins.attrib import attr
class TestData(object):
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/component/test_usage.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_usage.py b/test/integration/component/test_usage.py
index 5979a0a..00bb142 100644
--- a/test/integration/component/test_usage.py
+++ b/test/integration/component/test_usage.py
@@ -21,9 +21,9 @@ import marvin
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from marvin.sshClient import SshClient
import datetime
[2/6] CLOUDSTACK-6006: Remove integration folder and lib
Posted by gi...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/tools/marvin/marvin/lib/base.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/lib/base.py b/tools/marvin/marvin/lib/base.py
new file mode 100755
index 0000000..aa23029
--- /dev/null
+++ b/tools/marvin/marvin/lib/base.py
@@ -0,0 +1,3625 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+""" Base class for all Cloudstack resources
+ -Virtual machine, Volume, Snapshot etc
+"""
+
+import marvin
+from utils import is_server_ssh_ready, random_gen
+from marvin.cloudstackAPI import *
+# Import System modules
+import time
+import hashlib
+import base64
+
+
+class Domain:
+ """ Domain Life Cycle """
+ def __init__(self, items):
+ self.__dict__.update(items)
+
+ @classmethod
+ def create(cls, apiclient, services, name=None, networkdomain=None,
+ parentdomainid=None):
+ """Creates an domain"""
+
+ cmd = createDomain.createDomainCmd()
+
+ if "domainUUID" in services:
+ cmd.domainid = "-".join([services["domainUUID"], random_gen()])
+
+ if name:
+ cmd.name = "-".join([name, random_gen()])
+ elif "name" in services:
+ cmd.name = "-".join([services["name"], random_gen()])
+
+ if networkdomain:
+ cmd.networkdomain = networkdomain
+ elif "networkdomain" in services:
+ cmd.networkdomain = services["networkdomain"]
+
+ if parentdomainid:
+ cmd.parentdomainid = parentdomainid
+ elif "parentdomainid" in services:
+ cmd.parentdomainid = services["parentdomainid"]
+ try:
+ domain = apiclient.createDomain(cmd)
+ if domain is not None:
+ return Domain(domain.__dict__)
+ except Exception as e:
+ raise e
+
+ def delete(self, apiclient, cleanup=None):
+ """Delete an domain"""
+ cmd = deleteDomain.deleteDomainCmd()
+ cmd.id = self.id
+ if cleanup:
+ cmd.cleanup = cleanup
+ apiclient.deleteDomain(cmd)
+
+ @classmethod
+ def list(cls, apiclient, **kwargs):
+ """Lists domains"""
+ cmd = listDomains.listDomainsCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listDomains(cmd))
+
+
+class Account:
+ """ Account Life Cycle """
+ def __init__(self, items):
+ self.__dict__.update(items)
+
+ @classmethod
+ def create(cls, apiclient, services, admin=False, domainid=None):
+ """Creates an account"""
+ cmd = createAccount.createAccountCmd()
+
+ # 0 - User, 1 - Root Admin, 2 - Domain Admin
+ cmd.accounttype = 2 if (admin and domainid) else int(admin)
+
+ cmd.email = services["email"]
+ cmd.firstname = services["firstname"]
+ cmd.lastname = services["lastname"]
+
+ cmd.password = services["password"]
+
+ username = "-".join([services["username"], random_gen(id=apiclient.id)])
+ # Trim username to 99 characters to prevent failure
+ cmd.username = username[:99] if len(username) > 99 else username
+
+ if "accountUUID" in services:
+ cmd.accountid = "-".join([services["accountUUID"],random_gen()])
+
+ if "userUUID" in services:
+ cmd.userid = "-".join([services["userUUID"],random_gen()])
+
+
+ if domainid:
+ cmd.domainid = domainid
+ account = apiclient.createAccount(cmd)
+
+ return Account(account.__dict__)
+
+ def delete(self, apiclient):
+ """Delete an account"""
+ cmd = deleteAccount.deleteAccountCmd()
+ cmd.id = self.id
+ apiclient.deleteAccount(cmd)
+
+ @classmethod
+ def list(cls, apiclient, **kwargs):
+ """Lists accounts and provides detailed account information for
+ listed accounts"""
+
+ cmd = listAccounts.listAccountsCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listAccounts(cmd))
+
+
+class User:
+ """ User Life Cycle """
+ def __init__(self, items):
+ self.__dict__.update(items)
+
+ @classmethod
+ def create(cls, apiclient, services, account, domainid):
+ cmd = createUser.createUserCmd()
+ """Creates an user"""
+
+ cmd.account = account
+ cmd.domainid = domainid
+ cmd.email = services["email"]
+ cmd.firstname = services["firstname"]
+ cmd.lastname = services["lastname"]
+
+ if "userUUID" in services:
+ cmd.userid = "-".join([services["userUUID"],random_gen()])
+
+ cmd.password = services["password"]
+ cmd.username = "-".join([services["username"], random_gen()])
+ user = apiclient.createUser(cmd)
+
+ return User(user.__dict__)
+
+ def delete(self, apiclient):
+ """Delete an account"""
+ cmd = deleteUser.deleteUserCmd()
+ cmd.id = self.id
+ apiclient.deleteUser(cmd)
+
+ @classmethod
+ def list(cls, apiclient, **kwargs):
+ """Lists users and provides detailed account information for
+ listed users"""
+
+ cmd = listUsers.listUsersCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listUsers(cmd))
+
+ @classmethod
+ def registerUserKeys(cls, apiclient, userid):
+ cmd = registerUserKeys.registerUserKeysCmd()
+ cmd.id = userid
+ return apiclient.registerUserKeys(cmd)
+
+ def update(self, apiclient, **kwargs):
+ """Updates the user details"""
+
+ cmd = updateUser.updateUserCmd()
+ cmd.id = self.id
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return (apiclient.updateUser(cmd))
+
+ @classmethod
+ def update(cls, apiclient, id, **kwargs):
+ """Updates the user details (class method)"""
+
+ cmd = updateUser.updateUserCmd()
+ cmd.id = id
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return (apiclient.updateUser(cmd))
+
+ @classmethod
+ def login(cls, apiclient, username, password, domain=None, domainid=None):
+ """Logins to the CloudStack"""
+
+ cmd = login.loginCmd()
+ cmd.username = username
+ cmd.password = password
+ if domain:
+ cmd.domain = domain
+ if domainid:
+ cmd.domainId = domainid
+ return apiclient.login(cmd)
+
+
+class VirtualMachine:
+ """Manage virtual machine lifecycle"""
+
+ def __init__(self, items, services):
+ self.__dict__.update(items)
+ if "username" in services:
+ self.username = services["username"]
+ else:
+ self.username = 'root'
+ if "password" in services:
+ self.password = services["password"]
+ else:
+ self.password = 'password'
+ if "ssh_port" in services:
+ self.ssh_port = services["ssh_port"]
+ else:
+ self.ssh_port = 22
+ self.ssh_client = None
+ # extract out the ipaddress
+ self.ipaddress = self.nic[0].ipaddress
+
+ @classmethod
+ def ssh_access_group(cls, apiclient, cmd):
+ """
+ Programs the security group with SSH access before deploying virtualmachine
+ @return:
+ """
+ zone_list = Zone.list(
+ apiclient,
+ id=cmd.zoneid if cmd.zoneid else None,
+ domainid=cmd.domainid if cmd.domainid else None
+ )
+ zone = zone_list[0]
+ #check if security groups settings is enabled for the zone
+ if zone.securitygroupsenabled:
+ list_security_groups = SecurityGroup.list(
+ apiclient,
+ account=cmd.account,
+ domainid=cmd.domainid,
+ securitygroupname="basic_sec_grp"
+ )
+
+ if not isinstance(list_security_groups, list):
+ basic_mode_security_group = SecurityGroup.create(
+ apiclient,
+ {"name": "basic_sec_grp"},
+ cmd.account,
+ cmd.domainid,
+ )
+ sec_grp_services = {
+ "protocol": "TCP",
+ "startport": 22,
+ "endport": 22,
+ "cidrlist": "0.0.0.0/0"
+ }
+ #Authorize security group for above ingress rule
+ basic_mode_security_group.authorize(apiclient, sec_grp_services, account=cmd.account,
+ domainid=cmd.domainid)
+ else:
+ basic_mode_security_group = list_security_groups[0]
+
+ if isinstance(cmd.securitygroupids, list):
+ cmd.securitygroupids.append(basic_mode_security_group.id)
+ else:
+ cmd.securitygroupids = [basic_mode_security_group.id]
+
+ @classmethod
+ def access_ssh_over_nat(cls, apiclient, services, virtual_machine, allow_egress=False):
+ """
+ Program NAT and PF rules to open up ssh access to deployed guest
+ @return:
+ """
+ public_ip = PublicIPAddress.create(
+ apiclient=apiclient,
+ accountid=virtual_machine.account,
+ zoneid=virtual_machine.zoneid,
+ domainid=virtual_machine.domainid,
+ services=services
+ )
+ FireWallRule.create(
+ apiclient=apiclient,
+ ipaddressid=public_ip.ipaddress.id,
+ protocol='TCP',
+ cidrlist=['0.0.0.0/0'],
+ startport=22,
+ endport=22
+ )
+ nat_rule = NATRule.create(
+ apiclient=apiclient,
+ virtual_machine=virtual_machine,
+ services=services,
+ ipaddressid=public_ip.ipaddress.id
+ )
+ if allow_egress:
+ EgressFireWallRule.create(
+ apiclient=apiclient,
+ networkid=virtual_machine.nic[0].networkid,
+ protocol='All',
+ cidrlist='0.0.0.0/0'
+ )
+ virtual_machine.ssh_ip = nat_rule.ipaddress
+ virtual_machine.public_ip = nat_rule.ipaddress
+
+ @classmethod
+ def create(cls, apiclient, services, templateid=None, accountid=None,
+ domainid=None, zoneid=None, networkids=None, serviceofferingid=None,
+ securitygroupids=None, projectid=None, startvm=None,
+ diskofferingid=None, affinitygroupnames=None, affinitygroupids=None, group=None,
+ hostid=None, keypair=None, ipaddress=None, mode='default', method='GET'):
+ """Create the instance"""
+
+ cmd = deployVirtualMachine.deployVirtualMachineCmd()
+
+ if serviceofferingid:
+ cmd.serviceofferingid = serviceofferingid
+ elif "serviceoffering" in services:
+ cmd.serviceofferingid = services["serviceoffering"]
+
+ if zoneid:
+ cmd.zoneid = zoneid
+ elif "zoneid" in services:
+ cmd.zoneid = services["zoneid"]
+ cmd.hypervisor = apiclient.hypervisor
+
+ if "displayname" in services:
+ cmd.displayname = services["displayname"]
+
+ if "name" in services:
+ cmd.name = services["name"]
+
+ if accountid:
+ cmd.account = accountid
+ elif "account" in services:
+ cmd.account = services["account"]
+
+ if domainid:
+ cmd.domainid = domainid
+ elif "domainid" in services:
+ cmd.domainid = services["domainid"]
+
+ if networkids:
+ cmd.networkids = networkids
+ allow_egress = False
+ elif "networkids" in services:
+ cmd.networkids = services["networkids"]
+ allow_egress = False
+ else:
+ # When no networkids are passed, network
+ # is created using the "defaultOfferingWithSourceNAT"
+ # which has an egress policy of DENY. But guests in tests
+ # need access to test network connectivity
+ allow_egress = True
+
+ if templateid:
+ cmd.templateid = templateid
+ elif "template" in services:
+ cmd.templateid = services["template"]
+
+ if diskofferingid:
+ cmd.diskofferingid = diskofferingid
+ elif "diskoffering" in services:
+ cmd.diskofferingid = services["diskoffering"]
+
+ if keypair:
+ cmd.keypair = keypair
+ elif "keypair" in services:
+ cmd.keypair = services["keypair"]
+
+ if ipaddress:
+ cmd.ipaddress = ipaddress
+ elif ipaddress in services:
+ cmd.ipaddress = services["ipaddress"]
+
+ if securitygroupids:
+ cmd.securitygroupids = [str(sg_id) for sg_id in securitygroupids]
+
+ if "affinitygroupnames" in services:
+ cmd.affinitygroupnames = services["affinitygroupnames"]
+ elif affinitygroupnames:
+ cmd.affinitygroupnames = affinitygroupnames
+
+ if affinitygroupids:
+ cmd.affinitygroupids = affinitygroupids
+
+ if projectid:
+ cmd.projectid = projectid
+
+ if startvm is not None:
+ cmd.startvm = startvm
+
+ if hostid:
+ cmd.hostid = hostid
+
+ if "userdata" in services:
+ cmd.userdata = base64.urlsafe_b64encode(services["userdata"])
+
+ if group:
+ cmd.group = group
+
+ #program default access to ssh
+ if mode.lower() == 'basic':
+ cls.ssh_access_group(apiclient, cmd)
+
+ virtual_machine = apiclient.deployVirtualMachine(cmd, method=method)
+
+ virtual_machine.ssh_ip = virtual_machine.nic[0].ipaddress
+ if startvm == False:
+ virtual_machine.public_ip = virtual_machine.nic[0].ipaddress
+ return VirtualMachine(virtual_machine.__dict__, services)
+
+ #program ssh access over NAT via PF
+ if mode.lower() == 'advanced':
+ cls.access_ssh_over_nat(apiclient, services, virtual_machine, allow_egress=allow_egress)
+ elif mode.lower() == 'basic':
+ if virtual_machine.publicip is not None:
+ vm_ssh_ip = virtual_machine.publicip #EIP/ELB (netscaler) enabled zone
+ else:
+ vm_ssh_ip = virtual_machine.nic[0].ipaddress #regular basic zone with security group
+ virtual_machine.ssh_ip = vm_ssh_ip
+ virtual_machine.public_ip = vm_ssh_ip
+
+ return VirtualMachine(virtual_machine.__dict__, services)
+
+ def start(self, apiclient):
+ """Start the instance"""
+ cmd = startVirtualMachine.startVirtualMachineCmd()
+ cmd.id = self.id
+ apiclient.startVirtualMachine(cmd)
+
+ def stop(self, apiclient):
+ """Stop the instance"""
+ cmd = stopVirtualMachine.stopVirtualMachineCmd()
+ cmd.id = self.id
+ apiclient.stopVirtualMachine(cmd)
+
+ def reboot(self, apiclient):
+ """Reboot the instance"""
+ cmd = rebootVirtualMachine.rebootVirtualMachineCmd()
+ cmd.id = self.id
+ apiclient.rebootVirtualMachine(cmd)
+
+ def recover(self, apiclient):
+ """Recover the instance"""
+ cmd = recoverVirtualMachine.recoverVirtualMachineCmd()
+ cmd.id = self.id
+ apiclient.recoverVirtualMachine(cmd)
+
+ def restore(self, apiclient, templateid=None):
+ """Restore the instance"""
+ cmd = restoreVirtualMachine.restoreVirtualMachineCmd()
+ cmd.virtualmachineid = self.id
+ if templateid:
+ cmd.templateid = templateid
+ return apiclient.restoreVirtualMachine(cmd)
+
+ def get_ssh_client(self, ipaddress=None, reconnect=False, port=None, keyPairFileLocation=None):
+ """Get SSH object of VM"""
+
+ # If NAT Rules are not created while VM deployment in Advanced mode
+ # then, IP address must be passed
+ if ipaddress != None:
+ self.ssh_ip = ipaddress
+ if port:
+ self.ssh_port = port
+
+ if keyPairFileLocation is not None:
+ self.password = None
+
+ if reconnect:
+ self.ssh_client = is_server_ssh_ready(
+ self.ssh_ip,
+ self.ssh_port,
+ self.username,
+ self.password,
+ keyPairFileLocation=keyPairFileLocation
+ )
+ self.ssh_client = self.ssh_client or is_server_ssh_ready(
+ self.ssh_ip,
+ self.ssh_port,
+ self.username,
+ self.password,
+ keyPairFileLocation=keyPairFileLocation
+ )
+ return self.ssh_client
+
+ def resetSshKey(self, apiclient, **kwargs):
+ """Resets SSH key"""
+
+ cmd = resetSSHKeyForVirtualMachine.resetSSHKeyForVirtualMachineCmd()
+ cmd.id = self.id
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.resetSSHKeyForVirtualMachine(cmd))
+
+ def update(self, apiclient, **kwargs):
+ """Updates the VM data"""
+
+ cmd = updateVirtualMachine.updateVirtualMachineCmd()
+ cmd.id = self.id
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.updateVirtualMachine(cmd))
+
+ def delete(self, apiclient):
+ """Destroy an Instance"""
+ cmd = destroyVirtualMachine.destroyVirtualMachineCmd()
+ cmd.id = self.id
+ apiclient.destroyVirtualMachine(cmd)
+
+ def migrate(self, apiclient, hostid=None):
+ """migrate an Instance"""
+ cmd = migrateVirtualMachine.migrateVirtualMachineCmd()
+ cmd.virtualmachineid = self.id
+ if hostid:
+ cmd.hostid = hostid
+ apiclient.migrateVirtualMachine(cmd)
+
+ def attach_volume(self, apiclient, volume):
+ """Attach volume to instance"""
+ cmd = attachVolume.attachVolumeCmd()
+ cmd.id = volume.id
+ cmd.virtualmachineid = self.id
+ return apiclient.attachVolume(cmd)
+
+ def detach_volume(self, apiclient, volume):
+ """Detach volume to instance"""
+ cmd = detachVolume.detachVolumeCmd()
+ cmd.id = volume.id
+ return apiclient.detachVolume(cmd)
+
+ def add_nic(self, apiclient, networkId, ipaddress=None):
+ """Add a NIC to a VM"""
+ cmd = addNicToVirtualMachine.addNicToVirtualMachineCmd()
+ cmd.virtualmachineid = self.id
+ cmd.networkid = networkId
+
+ if ipaddress:
+ cmd.ipaddress = ipaddress
+
+ return apiclient.addNicToVirtualMachine(cmd)
+
+ def remove_nic(self, apiclient, nicId):
+ """Remove a NIC to a VM"""
+ cmd = removeNicFromVirtualMachine.removeNicFromVirtualMachineCmd()
+ cmd.nicid = nicId
+ cmd.virtualmachineid = self.id
+ return apiclient.removeNicFromVirtualMachine(cmd)
+
+ def update_default_nic(self, apiclient, nicId):
+ """Set a NIC to be the default network adapter for a VM"""
+ cmd = updateDefaultNicForVirtualMachine.updateDefaultNicForVirtualMachineCmd()
+ cmd.nicid = nicId
+ cmd.virtualmachineid = self.id
+ return apiclient.updateDefaultNicForVirtualMachine(cmd)
+
+ def attach_iso(self, apiclient, iso):
+ """Attach ISO to instance"""
+ cmd = attachIso.attachIsoCmd()
+ cmd.id = iso.id
+ cmd.virtualmachineid = self.id
+ return apiclient.attachIso(cmd)
+
+ def detach_iso(self, apiclient):
+ """Detach ISO to instance"""
+ cmd = detachIso.detachIsoCmd()
+ cmd.id = self.id
+ return apiclient.detachIso(cmd)
+
+ def change_service_offering(self, apiclient, serviceOfferingId):
+ """Change service offering of the instance"""
+ cmd = changeServiceForVirtualMachine.changeServiceForVirtualMachineCmd()
+ cmd.id = self.id
+ cmd.serviceofferingid = serviceOfferingId
+ return apiclient.changeServiceForVirtualMachine(cmd)
+
+ @classmethod
+ def list(cls, apiclient, **kwargs):
+ """List all VMs matching criteria"""
+
+ cmd = listVirtualMachines.listVirtualMachinesCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listVirtualMachines(cmd))
+
+ def resetPassword(self, apiclient):
+ """Resets VM password if VM created using password enabled template"""
+
+ cmd = resetPasswordForVirtualMachine.resetPasswordForVirtualMachineCmd()
+ cmd.id = self.id
+ try:
+ response = apiclient.resetPasswordForVirtualMachine(cmd)
+ except Exception as e:
+ raise Exception("Reset Password failed! - %s" % e)
+ if response is not None:
+ return response.password
+
+ def assign_virtual_machine(self, apiclient, account, domainid):
+ """Move a user VM to another user under same domain."""
+
+ cmd = assignVirtualMachine.assignVirtualMachineCmd()
+ cmd.virtualmachineid = self.id
+ cmd.account = account
+ cmd.domainid = domainid
+ try:
+ response = apiclient.assignVirtualMachine(cmd)
+ return response
+ except Exception as e:
+ raise Exception("assignVirtualMachine failed - %s" %e)
+
+ def update_affinity_group(self, apiclient, affinitygroupids=None,
+ affinitygroupnames=None):
+ """Update affinity group of a VM"""
+ cmd = updateVMAffinityGroup.updateVMAffinityGroupCmd()
+ cmd.id = self.id
+
+ if affinitygroupids:
+ cmd.affinitygroupids = affinitygroupids
+
+ if affinitygroupnames:
+ cmd.affinitygroupnames = affinitygroupnames
+
+ return apiclient.updateVMAffinityGroup(cmd)
+
+
+class Volume:
+ """Manage Volume Life cycle
+ """
+ def __init__(self, items):
+ self.__dict__.update(items)
+
+ @classmethod
+ def create(cls, apiclient, services, zoneid=None, account=None,
+ domainid=None, diskofferingid=None, projectid=None):
+ """Create Volume"""
+ cmd = createVolume.createVolumeCmd()
+ cmd.name = services["diskname"]
+
+ if diskofferingid:
+ cmd.diskofferingid = diskofferingid
+ elif "diskofferingid" in services:
+ cmd.diskofferingid = services["diskofferingid"]
+
+ if zoneid:
+ cmd.zoneid = zoneid
+ elif "zoneid" in services:
+ cmd.zoneid = services["zoneid"]
+
+ if account:
+ cmd.account = account
+ elif "account" in services:
+ cmd.account = services["account"]
+
+ if domainid:
+ cmd.domainid = domainid
+ elif "domainid" in services:
+ cmd.domainid = services["domainid"]
+
+ if projectid:
+ cmd.projectid = projectid
+ return Volume(apiclient.createVolume(cmd).__dict__)
+
+ @classmethod
+ def create_custom_disk(cls, apiclient, services, account=None,
+ domainid=None, diskofferingid=None):
+ """Create Volume from Custom disk offering"""
+ cmd = createVolume.createVolumeCmd()
+ cmd.name = services["diskname"]
+
+ if diskofferingid:
+ cmd.diskofferingid = diskofferingid
+ elif "customdiskofferingid" in services:
+ cmd.diskofferingid = services["customdiskofferingid"]
+
+ cmd.size = services["customdisksize"]
+ cmd.zoneid = services["zoneid"]
+
+ if account:
+ cmd.account = account
+ else:
+ cmd.account = services["account"]
+
+ if domainid:
+ cmd.domainid = domainid
+ else:
+ cmd.domainid = services["domainid"]
+
+ return Volume(apiclient.createVolume(cmd).__dict__)
+
+ @classmethod
+ def create_from_snapshot(cls, apiclient, snapshot_id, services,
+ account=None, domainid=None):
+ """Create Volume from snapshot"""
+ cmd = createVolume.createVolumeCmd()
+ cmd.name = "-".join([services["diskname"], random_gen()])
+ cmd.snapshotid = snapshot_id
+ cmd.zoneid = services["zoneid"]
+ cmd.size = services["size"]
+ if account:
+ cmd.account = account
+ else:
+ cmd.account = services["account"]
+ if domainid:
+ cmd.domainid = domainid
+ else:
+ cmd.domainid = services["domainid"]
+ return Volume(apiclient.createVolume(cmd).__dict__)
+
+ def delete(self, apiclient):
+ """Delete Volume"""
+ cmd = deleteVolume.deleteVolumeCmd()
+ cmd.id = self.id
+ apiclient.deleteVolume(cmd)
+
+ @classmethod
+ def list(cls, apiclient, **kwargs):
+ """List all volumes matching criteria"""
+
+ cmd = listVolumes.listVolumesCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listVolumes(cmd))
+
+ def resize(self, apiclient, **kwargs):
+ """Resize a volume"""
+ cmd = resizeVolume.resizeVolumeCmd()
+ cmd.id = self.id
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.resizeVolume(cmd))
+
+ @classmethod
+ def upload(cls, apiclient, services, zoneid=None, account=None, domainid=None, url=None):
+ """Uploads the volume to specified account"""
+
+ cmd = uploadVolume.uploadVolumeCmd()
+ if zoneid:
+ cmd.zoneid = zoneid
+ if account:
+ cmd.account = account
+ if domainid:
+ cmd.domainid = domainid
+ cmd.format = services["format"]
+ cmd.name = services["diskname"]
+ if url:
+ cmd.url = url
+ else:
+ cmd.url = services["url"]
+ return Volume(apiclient.uploadVolume(cmd).__dict__)
+
+ def wait_for_upload(self, apiclient, timeout=10, interval=60):
+ """Wait for upload"""
+ # Sleep to ensure template is in proper state before download
+ time.sleep(interval)
+
+ while True:
+ volume_response = Volume.list(
+ apiclient,
+ id=self.id,
+ zoneid=self.zoneid,
+ )
+ if isinstance(volume_response, list):
+
+ volume = volume_response[0]
+ # If volume is ready,
+ # volume.state = Allocated
+ if volume.state == 'Uploaded':
+ break
+
+ elif 'Uploading' in volume.state:
+ time.sleep(interval)
+
+ elif 'Installing' not in volume.state:
+ raise Exception(
+ "Error in uploading volume: status - %s" %
+ volume.state)
+ elif timeout == 0:
+ break
+
+ else:
+ time.sleep(interval)
+ timeout = timeout - 1
+ return
+
+ @classmethod
+ def migrate(cls, apiclient, **kwargs):
+ """Migrate a volume"""
+ cmd = migrateVolume.migrateVolumeCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.migrateVolume(cmd))
+
+class Snapshot:
+ """Manage Snapshot Lifecycle
+ """
+ def __init__(self, items):
+ self.__dict__.update(items)
+
+ @classmethod
+ def create(cls, apiclient, volume_id, account=None,
+ domainid=None, projectid=None):
+ """Create Snapshot"""
+ cmd = createSnapshot.createSnapshotCmd()
+ cmd.volumeid = volume_id
+ if account:
+ cmd.account = account
+ if domainid:
+ cmd.domainid = domainid
+ if projectid:
+ cmd.projectid = projectid
+ return Snapshot(apiclient.createSnapshot(cmd).__dict__)
+
+ def delete(self, apiclient):
+ """Delete Snapshot"""
+ cmd = deleteSnapshot.deleteSnapshotCmd()
+ cmd.id = self.id
+ apiclient.deleteSnapshot(cmd)
+
+ @classmethod
+ def list(cls, apiclient, **kwargs):
+ """List all snapshots matching criteria"""
+
+ cmd = listSnapshots.listSnapshotsCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listSnapshots(cmd))
+
+
+class Template:
+ """Manage template life cycle"""
+
+ def __init__(self, items):
+ self.__dict__.update(items)
+
+ @classmethod
+ def create(cls, apiclient, services, volumeid=None,
+ account=None, domainid=None, projectid=None):
+ """Create template from Volume"""
+ # Create template from Virtual machine and Volume ID
+ cmd = createTemplate.createTemplateCmd()
+ cmd.displaytext = services["displaytext"]
+ cmd.name = "-".join([services["name"], random_gen()])
+ if "ostypeid" in services:
+ cmd.ostypeid = services["ostypeid"]
+ elif "ostype" in services:
+ # Find OSTypeId from Os type
+ sub_cmd = listOsTypes.listOsTypesCmd()
+ sub_cmd.description = services["ostype"]
+ ostypes = apiclient.listOsTypes(sub_cmd)
+
+ if not isinstance(ostypes, list):
+ raise Exception(
+ "Unable to find Ostype id with desc: %s" %
+ services["ostype"])
+ cmd.ostypeid = ostypes[0].id
+ else:
+ raise Exception(
+ "Unable to find Ostype is required for creating template")
+
+ cmd.isfeatured = services["isfeatured"] if "isfeatured" in services else False
+ cmd.ispublic = services["ispublic"] if "ispublic" in services else False
+ cmd.isextractable = services["isextractable"] if "isextractable" in services else False
+ cmd.passwordenabled = services["passwordenabled"] if "passwordenabled" in services else False
+
+ if volumeid:
+ cmd.volumeid = volumeid
+
+ if account:
+ cmd.account = account
+
+ if domainid:
+ cmd.domainid = domainid
+
+ if projectid:
+ cmd.projectid = projectid
+ return Template(apiclient.createTemplate(cmd).__dict__)
+
+ @classmethod
+ def register(cls, apiclient, services, zoneid=None,
+ account=None, domainid=None):
+ """Create template from URL"""
+
+ # Create template from Virtual machine and Volume ID
+ cmd = registerTemplate.registerTemplateCmd()
+ cmd.displaytext = services["displaytext"]
+ cmd.name = "-".join([services["name"], random_gen()])
+ cmd.format = services["format"]
+ cmd.hypervisor = apiclient.hypervisor
+
+ if "ostypeid" in services:
+ cmd.ostypeid = services["ostypeid"]
+ elif "ostype" in services:
+ # Find OSTypeId from Os type
+ sub_cmd = listOsTypes.listOsTypesCmd()
+ sub_cmd.description = services["ostype"]
+ ostypes = apiclient.listOsTypes(sub_cmd)
+
+ if not isinstance(ostypes, list):
+ raise Exception(
+ "Unable to find Ostype id with desc: %s" %
+ services["ostype"])
+ cmd.ostypeid = ostypes[0].id
+ else:
+ raise Exception(
+ "Unable to find Ostype is required for registering template")
+
+ cmd.url = services["url"]
+
+ if zoneid:
+ cmd.zoneid = zoneid
+ else:
+ cmd.zoneid = services["zoneid"]
+
+ cmd.isfeatured = services["isfeatured"] if "isfeatured" in services else False
+ cmd.ispublic = services["ispublic"] if "ispublic" in services else False
+ cmd.isextractable = services["isextractable"] if "isextractable" in services else False
+ cmd.passwordenabled = services["passwordenabled"] if "passwordenabled" in services else False
+
+ if account:
+ cmd.account = account
+
+ if domainid:
+ cmd.domainid = domainid
+
+ # Register Template
+ template = apiclient.registerTemplate(cmd)
+
+ if isinstance(template, list):
+ return Template(template[0].__dict__)
+
+ @classmethod
+ def extract(cls, apiclient, id, mode, zoneid=None):
+ "Extract template "
+
+ cmd = extractTemplate.extractTemplateCmd()
+ cmd.id = id
+ cmd.mode = mode
+ cmd.zoneid = zoneid
+
+ return apiclient.extractTemplate(cmd)
+
+ @classmethod
+ def create_from_snapshot(cls, apiclient, snapshot, services,
+ random_name=True):
+ """Create Template from snapshot"""
+ # Create template from Virtual machine and Snapshot ID
+ cmd = createTemplate.createTemplateCmd()
+ cmd.displaytext = services["displaytext"]
+ cmd.name = "-".join([
+ services["name"],
+ random_gen()
+ ]) if random_name else services["name"]
+
+ if "ostypeid" in services:
+ cmd.ostypeid = services["ostypeid"]
+ elif "ostype" in services:
+ # Find OSTypeId from Os type
+ sub_cmd = listOsTypes.listOsTypesCmd()
+ sub_cmd.description = services["ostype"]
+ ostypes = apiclient.listOsTypes(sub_cmd)
+
+ if not isinstance(ostypes, list):
+ raise Exception(
+ "Unable to find Ostype id with desc: %s" %
+ services["ostype"])
+ cmd.ostypeid = ostypes[0].id
+ else:
+ raise Exception(
+ "Unable to find Ostype is required for creating template")
+
+ cmd.snapshotid = snapshot.id
+ return Template(apiclient.createTemplate(cmd).__dict__)
+
+ def delete(self, apiclient):
+ """Delete Template"""
+
+ cmd = deleteTemplate.deleteTemplateCmd()
+ cmd.id = self.id
+ apiclient.deleteTemplate(cmd)
+
+ def download(self, apiclient, timeout=5, interval=60):
+ """Download Template"""
+ # Sleep to ensure template is in proper state before download
+ time.sleep(interval)
+
+ while True:
+ template_response = Template.list(
+ apiclient,
+ id=self.id,
+ zoneid=self.zoneid,
+ templatefilter='self'
+ )
+ if isinstance(template_response, list):
+
+ template = template_response[0]
+ # If template is ready,
+ # template.status = Download Complete
+ # Downloading - x% Downloaded
+ # Error - Any other string
+ if template.status == 'Download Complete':
+ break
+
+ elif 'Downloaded' in template.status:
+ time.sleep(interval)
+
+ elif 'Installing' not in template.status:
+ raise Exception(
+ "Error in downloading template: status - %s" %
+ template.status)
+
+ elif timeout == 0:
+ break
+
+ else:
+ time.sleep(interval)
+ timeout = timeout - 1
+ return
+
+ def updatePermissions(self, apiclient, **kwargs):
+ """Updates the template permissions"""
+
+ cmd = updateTemplatePermissions.updateTemplatePermissionsCmd()
+ cmd.id = self.id
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.updateTemplatePermissions(cmd))
+
+ @classmethod
+ def list(cls, apiclient, **kwargs):
+ """List all templates matching criteria"""
+
+ cmd = listTemplates.listTemplatesCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listTemplates(cmd))
+
+
+class Iso:
+ """Manage ISO life cycle"""
+
+ def __init__(self, items):
+ self.__dict__.update(items)
+
+ @classmethod
+ def create(cls, apiclient, services, account=None, domainid=None,
+ projectid=None):
+ """Create an ISO"""
+ # Create ISO from URL
+ cmd = registerIso.registerIsoCmd()
+ cmd.displaytext = services["displaytext"]
+ cmd.name = services["name"]
+ if "ostypeid" in services:
+ cmd.ostypeid = services["ostypeid"]
+ elif "ostype" in services:
+ # Find OSTypeId from Os type
+ sub_cmd = listOsTypes.listOsTypesCmd()
+ sub_cmd.description = services["ostype"]
+ ostypes = apiclient.listOsTypes(sub_cmd)
+
+ if not isinstance(ostypes, list):
+ raise Exception(
+ "Unable to find Ostype id with desc: %s" %
+ services["ostype"])
+ cmd.ostypeid = ostypes[0].id
+ else:
+ raise Exception(
+ "Unable to find Ostype is required for creating ISO")
+
+ cmd.url = services["url"]
+ cmd.zoneid = services["zoneid"]
+
+ if "isextractable" in services:
+ cmd.isextractable = services["isextractable"]
+ if "isfeatured" in services:
+ cmd.isfeatured = services["isfeatured"]
+ if "ispublic" in services:
+ cmd.ispublic = services["ispublic"]
+
+ if account:
+ cmd.account = account
+ if domainid:
+ cmd.domainid = domainid
+ if projectid:
+ cmd.projectid = projectid
+ # Register ISO
+ iso = apiclient.registerIso(cmd)
+
+ if iso:
+ return Iso(iso[0].__dict__)
+
+ def delete(self, apiclient):
+ """Delete an ISO"""
+ cmd = deleteIso.deleteIsoCmd()
+ cmd.id = self.id
+ apiclient.deleteIso(cmd)
+ return
+
+ def download(self, apiclient, timeout=5, interval=60):
+ """Download an ISO"""
+ # Ensuring ISO is successfully downloaded
+ while True:
+ time.sleep(interval)
+
+ cmd = listIsos.listIsosCmd()
+ cmd.id = self.id
+ iso_response = apiclient.listIsos(cmd)
+
+ if isinstance(iso_response, list):
+ response = iso_response[0]
+ # Again initialize timeout to avoid listISO failure
+ timeout = 5
+ # Check whether download is in progress(for Ex:10% Downloaded)
+ # or ISO is 'Successfully Installed'
+ if response.status == 'Successfully Installed':
+ return
+ elif 'Downloaded' not in response.status and \
+ 'Installing' not in response.status:
+ raise Exception(
+ "Error In Downloading ISO: ISO Status - %s" %
+ response.status)
+
+ elif timeout == 0:
+ raise Exception("ISO download Timeout Exception")
+ else:
+ timeout = timeout - 1
+ return
+
+ @classmethod
+ def list(cls, apiclient, **kwargs):
+ """Lists all available ISO files."""
+
+ cmd = listIsos.listIsosCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listIsos(cmd))
+
+
+class PublicIPAddress:
+ """Manage Public IP Addresses"""
+
+ def __init__(self, items):
+ self.__dict__.update(items)
+
+ @classmethod
+ def create(cls, apiclient, accountid=None, zoneid=None, domainid=None, services=None,
+ networkid=None, projectid=None, vpcid=None, isportable=False):
+ """Associate Public IP address"""
+ cmd = associateIpAddress.associateIpAddressCmd()
+
+ if accountid:
+ cmd.account = accountid
+ elif "account" in services:
+ cmd.account = services["account"]
+
+ if zoneid:
+ cmd.zoneid = zoneid
+ elif "zoneid" in services:
+ cmd.zoneid = services["zoneid"]
+
+ if domainid:
+ cmd.domainid = domainid
+ elif "domainid" in services:
+ cmd.domainid = services["domainid"]
+
+ if isportable:
+ cmd.isportable = isportable
+
+ if networkid:
+ cmd.networkid = networkid
+
+ if projectid:
+ cmd.projectid = projectid
+
+ if vpcid:
+ cmd.vpcid = vpcid
+ return PublicIPAddress(apiclient.associateIpAddress(cmd).__dict__)
+
+ def delete(self, apiclient):
+ """Dissociate Public IP address"""
+ cmd = disassociateIpAddress.disassociateIpAddressCmd()
+ cmd.id = self.ipaddress.id
+ apiclient.disassociateIpAddress(cmd)
+ return
+
+ @classmethod
+ def list(cls, apiclient, **kwargs):
+ """List all Public IPs matching criteria"""
+
+ cmd = listPublicIpAddresses.listPublicIpAddressesCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listPublicIpAddresses(cmd))
+
+
+class NATRule:
+ """Manage port forwarding rule"""
+
+ def __init__(self, items):
+ self.__dict__.update(items)
+
+ @classmethod
+ def create(cls, apiclient, virtual_machine, services, ipaddressid=None,
+ projectid=None, openfirewall=False, networkid=None, vpcid=None):
+ """Create Port forwarding rule"""
+ cmd = createPortForwardingRule.createPortForwardingRuleCmd()
+
+ if ipaddressid:
+ cmd.ipaddressid = ipaddressid
+ elif "ipaddressid" in services:
+ cmd.ipaddressid = services["ipaddressid"]
+
+ cmd.privateport = services["privateport"]
+ cmd.publicport = services["publicport"]
+ if "privateendport" in services:
+ cmd.privateendport = services["privateendport"]
+ if "publicendport" in services:
+ cmd.publicendport = services["publicendport"]
+ cmd.protocol = services["protocol"]
+ cmd.virtualmachineid = virtual_machine.id
+
+ if projectid:
+ cmd.projectid = projectid
+
+ if openfirewall:
+ cmd.openfirewall = True
+
+ if networkid:
+ cmd.networkid = networkid
+
+ if vpcid:
+ cmd.vpcid = vpcid
+ return NATRule(apiclient.createPortForwardingRule(cmd).__dict__)
+
+ def delete(self, apiclient):
+ """Delete port forwarding"""
+ cmd = deletePortForwardingRule.deletePortForwardingRuleCmd()
+ cmd.id = self.id
+ apiclient.deletePortForwardingRule(cmd)
+ return
+
+ @classmethod
+ def list(cls, apiclient, **kwargs):
+ """List all NAT rules matching criteria"""
+
+ cmd = listPortForwardingRules.listPortForwardingRulesCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listPortForwardingRules(cmd))
+
+
+class StaticNATRule:
+ """Manage Static NAT rule"""
+
+ def __init__(self, items):
+ self.__dict__.update(items)
+
+ @classmethod
+ def create(cls, apiclient, services, ipaddressid=None, networkid=None, vpcid=None):
+ """Creates static ip forwarding rule"""
+
+ cmd = createFirewallRule.createFirewallRuleCmd()
+ cmd.protocol = services["protocol"]
+ cmd.startport = services["startport"]
+
+ if "endport" in services:
+ cmd.endport = services["endport"]
+
+ if "cidrlist" in services:
+ cmd.cidrlist = services["cidrlist"]
+
+ if ipaddressid:
+ cmd.ipaddressid = ipaddressid
+ elif "ipaddressid" in services:
+ cmd.ipaddressid = services["ipaddressid"]
+
+ if networkid:
+ cmd.networkid = networkid
+
+ if vpcid:
+ cmd.vpcid = vpcid
+ return StaticNATRule(apiclient.createFirewallRule(cmd).__dict__)
+
+ def delete(self, apiclient):
+ """Delete IP forwarding rule"""
+ cmd = deleteIpForwardingRule.deleteIpForwardingRuleCmd()
+ cmd.id = self.id
+ apiclient.deleteIpForwardingRule(cmd)
+ return
+
+ @classmethod
+ def list(cls, apiclient, **kwargs):
+ """List all IP forwarding rules matching criteria"""
+
+ cmd = listIpForwardingRules.listIpForwardingRulesCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listIpForwardingRules(cmd))
+
+ @classmethod
+ def enable(cls, apiclient, ipaddressid, virtualmachineid, networkid=None):
+ """Enables Static NAT rule"""
+
+ cmd = enableStaticNat.enableStaticNatCmd()
+ cmd.ipaddressid = ipaddressid
+ cmd.virtualmachineid = virtualmachineid
+ if networkid:
+ cmd.networkid = networkid
+ apiclient.enableStaticNat(cmd)
+ return
+
+ @classmethod
+ def disable(cls, apiclient, ipaddressid, virtualmachineid):
+ """Disables Static NAT rule"""
+
+ cmd = disableStaticNat.disableStaticNatCmd()
+ cmd.ipaddressid = ipaddressid
+ apiclient.disableStaticNat(cmd)
+ return
+
+
+class EgressFireWallRule:
+ """Manage Egress Firewall rule"""
+
+ def __init__(self, items):
+ self.__dict__.update(items)
+
+ @classmethod
+ def create(cls, apiclient, networkid, protocol, cidrlist=None,
+ startport=None, endport=None):
+ """Create Egress Firewall Rule"""
+ cmd = createEgressFirewallRule.createEgressFirewallRuleCmd()
+ cmd.networkid = networkid
+ cmd.protocol = protocol
+ if cidrlist:
+ cmd.cidrlist = cidrlist
+ if startport:
+ cmd.startport = startport
+ if endport:
+ cmd.endport = endport
+
+ return EgressFireWallRule(apiclient.createEgressFirewallRule(cmd).__dict__)
+
+ def delete(self, apiclient):
+ """Delete Egress Firewall rule"""
+ cmd = deleteEgressFirewallRule.deleteEgressFirewallRuleCmd()
+ cmd.id = self.id
+ apiclient.deleteEgressFirewallRule(cmd)
+ return
+
+ @classmethod
+ def list(cls, apiclient, **kwargs):
+ """List all Egress Firewall Rules matching criteria"""
+
+ cmd = listEgressFirewallRules.listEgressFirewallRulesCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listEgressFirewallRules(cmd))
+
+
+
+class FireWallRule:
+ """Manage Firewall rule"""
+
+ def __init__(self, items):
+ self.__dict__.update(items)
+
+ @classmethod
+ def create(cls, apiclient, ipaddressid, protocol, cidrlist=None,
+ startport=None, endport=None, projectid=None, vpcid=None):
+ """Create Firewall Rule"""
+ cmd = createFirewallRule.createFirewallRuleCmd()
+ cmd.ipaddressid = ipaddressid
+ cmd.protocol = protocol
+ if cidrlist:
+ cmd.cidrlist = cidrlist
+ if startport:
+ cmd.startport = startport
+ if endport:
+ cmd.endport = endport
+
+ if projectid:
+ cmd.projectid = projectid
+
+ if vpcid:
+ cmd.vpcid = vpcid
+
+ return FireWallRule(apiclient.createFirewallRule(cmd).__dict__)
+
+ def delete(self, apiclient):
+ """Delete Firewall rule"""
+ cmd = deleteFirewallRule.deleteFirewallRuleCmd()
+ cmd.id = self.id
+ apiclient.deleteFirewallRule(cmd)
+ return
+
+ @classmethod
+ def list(cls, apiclient, **kwargs):
+ """List all Firewall Rules matching criteria"""
+
+ cmd = listFirewallRules.listFirewallRulesCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listFirewallRules(cmd))
+
+
+class ServiceOffering:
+ """Manage service offerings cycle"""
+
+ def __init__(self, items):
+ self.__dict__.update(items)
+
+ @classmethod
+ def create(cls, apiclient, services, domainid=None, **kwargs):
+ """Create Service offering"""
+ cmd = createServiceOffering.createServiceOfferingCmd()
+ cmd.cpunumber = services["cpunumber"]
+ cmd.cpuspeed = services["cpuspeed"]
+ cmd.displaytext = services["displaytext"]
+ cmd.memory = services["memory"]
+ cmd.name = services["name"]
+ if "storagetype" in services:
+ cmd.storagetype = services["storagetype"]
+
+ if "systemvmtype" in services:
+ cmd.systemvmtype = services['systemvmtype']
+
+ if "issystem" in services:
+ cmd.issystem = services['issystem']
+
+ if "tags" in services:
+ cmd.tags = services["tags"]
+
+ if "deploymentplanner" in services:
+ cmd.deploymentplanner = services["deploymentplanner"]
+
+ if "isvolatile" in services:
+ cmd.isvolatile = services["isvolatile"]
+
+ # Service Offering private to that domain
+ if domainid:
+ cmd.domainid = domainid
+
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return ServiceOffering(apiclient.createServiceOffering(cmd).__dict__)
+
+ def delete(self, apiclient):
+ """Delete Service offering"""
+ cmd = deleteServiceOffering.deleteServiceOfferingCmd()
+ cmd.id = self.id
+ apiclient.deleteServiceOffering(cmd)
+ return
+
+ @classmethod
+ def list(cls, apiclient, **kwargs):
+ """Lists all available service offerings."""
+
+ cmd = listServiceOfferings.listServiceOfferingsCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listServiceOfferings(cmd))
+
+
+class DiskOffering:
+ """Manage disk offerings cycle"""
+
+ def __init__(self, items):
+ self.__dict__.update(items)
+
+ @classmethod
+ def create(cls, apiclient, services, custom=False, domainid=None):
+ """Create Disk offering"""
+ cmd = createDiskOffering.createDiskOfferingCmd()
+ cmd.displaytext = services["displaytext"]
+ cmd.name = services["name"]
+ if custom:
+ cmd.customized = True
+ else:
+ cmd.disksize = services["disksize"]
+
+ if domainid:
+ cmd.domainid = domainid
+
+ if "storagetype" in services:
+ cmd.storagetype = services["storagetype"]
+
+ return DiskOffering(apiclient.createDiskOffering(cmd).__dict__)
+
+ def delete(self, apiclient):
+ """Delete Disk offering"""
+ cmd = deleteDiskOffering.deleteDiskOfferingCmd()
+ cmd.id = self.id
+ apiclient.deleteDiskOffering(cmd)
+ return
+
+ @classmethod
+ def list(cls, apiclient, **kwargs):
+ """Lists all available disk offerings."""
+
+ cmd = listDiskOfferings.listDiskOfferingsCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listDiskOfferings(cmd))
+
+
+class NetworkOffering:
+ """Manage network offerings cycle"""
+
+ def __init__(self, items):
+ self.__dict__.update(items)
+
+ @classmethod
+ def create(cls, apiclient, services, **kwargs):
+ """Create network offering"""
+
+ cmd = createNetworkOffering.createNetworkOfferingCmd()
+ cmd.displaytext = "-".join([services["displaytext"], random_gen()])
+ cmd.name = "-".join([services["name"], random_gen()])
+ cmd.guestiptype = services["guestiptype"]
+ cmd.supportedservices = ''
+ if "supportedservices" in services:
+ cmd.supportedservices = services["supportedservices"]
+ cmd.traffictype = services["traffictype"]
+
+ if "useVpc" in services:
+ cmd.useVpc = services["useVpc"]
+ cmd.serviceproviderlist = []
+ if "serviceProviderList" in services:
+ for service, provider in services["serviceProviderList"].items():
+ cmd.serviceproviderlist.append({
+ 'service': service,
+ 'provider': provider
+ })
+ if "serviceCapabilityList" in services:
+ cmd.servicecapabilitylist = []
+ for service, capability in services["serviceCapabilityList"].items():
+ for ctype, value in capability.items():
+ cmd.servicecapabilitylist.append({
+ 'service': service,
+ 'capabilitytype': ctype,
+ 'capabilityvalue': value
+ })
+ if "specifyVlan" in services:
+ cmd.specifyVlan = services["specifyVlan"]
+ if "specifyIpRanges" in services:
+ cmd.specifyIpRanges = services["specifyIpRanges"]
+ if "ispersistent" in services:
+ cmd.ispersistent = services["ispersistent"]
+ if "egress_policy" in services:
+ cmd.egressdefaultpolicy = services["egress_policy"]
+
+ cmd.availability = 'Optional'
+
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+
+ return NetworkOffering(apiclient.createNetworkOffering(cmd).__dict__)
+
+ def delete(self, apiclient):
+ """Delete network offering"""
+ cmd = deleteNetworkOffering.deleteNetworkOfferingCmd()
+ cmd.id = self.id
+ apiclient.deleteNetworkOffering(cmd)
+ return
+
+ def update(self, apiclient, **kwargs):
+ """Lists all available network offerings."""
+
+ cmd = updateNetworkOffering.updateNetworkOfferingCmd()
+ cmd.id = self.id
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.updateNetworkOffering(cmd))
+
+ @classmethod
+ def list(cls, apiclient, **kwargs):
+ """Lists all available network offerings."""
+
+ cmd = listNetworkOfferings.listNetworkOfferingsCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listNetworkOfferings(cmd))
+
+
+class SnapshotPolicy:
+ """Manage snapshot policies"""
+
+ def __init__(self, items):
+ self.__dict__.update(items)
+
+ @classmethod
+ def create(cls, apiclient, volumeid, services):
+ """Create Snapshot policy"""
+ cmd = createSnapshotPolicy.createSnapshotPolicyCmd()
+ cmd.intervaltype = services["intervaltype"]
+ cmd.maxsnaps = services["maxsnaps"]
+ cmd.schedule = services["schedule"]
+ cmd.timezone = services["timezone"]
+ cmd.volumeid = volumeid
+ return SnapshotPolicy(apiclient.createSnapshotPolicy(cmd).__dict__)
+
+ def delete(self, apiclient):
+ """Delete Snapshot policy"""
+ cmd = deleteSnapshotPolicies.deleteSnapshotPoliciesCmd()
+ cmd.id = self.id
+ apiclient.deleteSnapshotPolicies(cmd)
+ return
+
+ @classmethod
+ def list(cls, apiclient, **kwargs):
+ """Lists snapshot policies."""
+
+ cmd = listSnapshotPolicies.listSnapshotPoliciesCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listSnapshotPolicies(cmd))
+
+
+class LoadBalancerRule:
+ """Manage Load Balancer rule"""
+
+ def __init__(self, items):
+ self.__dict__.update(items)
+
+ @classmethod
+ def create(cls, apiclient, services, ipaddressid=None, accountid=None,
+ networkid=None, vpcid=None, projectid=None, domainid=None):
+ """Create Load balancing Rule"""
+
+ cmd = createLoadBalancerRule.createLoadBalancerRuleCmd()
+
+ if ipaddressid:
+ cmd.publicipid = ipaddressid
+ elif "ipaddressid" in services:
+ cmd.publicipid = services["ipaddressid"]
+
+ if accountid:
+ cmd.account = accountid
+ elif "account" in services:
+ cmd.account = services["account"]
+
+ if domainid:
+ cmd.domainid = domainid
+
+ if vpcid:
+ cmd.vpcid = vpcid
+ cmd.name = services["name"]
+ cmd.algorithm = services["alg"]
+ cmd.privateport = services["privateport"]
+ cmd.publicport = services["publicport"]
+
+ if "openfirewall" in services:
+ cmd.openfirewall = services["openfirewall"]
+
+ if projectid:
+ cmd.projectid = projectid
+
+ if networkid:
+ cmd.networkid = networkid
+ return LoadBalancerRule(apiclient.createLoadBalancerRule(cmd).__dict__)
+
+ def delete(self, apiclient):
+ """Delete load balancing rule"""
+ cmd = deleteLoadBalancerRule.deleteLoadBalancerRuleCmd()
+ cmd.id = self.id
+ apiclient.deleteLoadBalancerRule(cmd)
+ return
+
+ def assign(self, apiclient, vms):
+ """Assign virtual machines to load balancing rule"""
+ cmd = assignToLoadBalancerRule.assignToLoadBalancerRuleCmd()
+ cmd.id = self.id
+ cmd.virtualmachineids = [str(vm.id) for vm in vms]
+ apiclient.assignToLoadBalancerRule(cmd)
+ return
+
+ def remove(self, apiclient, vms):
+ """Remove virtual machines from load balancing rule"""
+ cmd = removeFromLoadBalancerRule.removeFromLoadBalancerRuleCmd()
+ cmd.id = self.id
+ cmd.virtualmachineids = [str(vm.id) for vm in vms]
+ apiclient.removeFromLoadBalancerRule(cmd)
+ return
+
+ def update(self, apiclient, algorithm=None, description=None, name=None, **kwargs):
+ """Updates the load balancing rule"""
+ cmd = updateLoadBalancerRule.updateLoadBalancerRuleCmd()
+ cmd.id = self.id
+ if algorithm:
+ cmd.algorithm = algorithm
+ if description:
+ cmd.description = description
+ if name:
+ cmd.name = name
+
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return apiclient.updateLoadBalancerRule(cmd)
+
+ def createSticky(self, apiclient, methodname, name, description=None, param=None):
+ """Creates a sticky policy for the LB rule"""
+
+ cmd = createLBStickinessPolicy.createLBStickinessPolicyCmd()
+ cmd.lbruleid = self.id
+ cmd.methodname = methodname
+ cmd.name = name
+ if description:
+ cmd.description = description
+ if param:
+ cmd.param = []
+ for name, value in param.items():
+ cmd.param.append({'name': name, 'value': value})
+ return apiclient.createLBStickinessPolicy(cmd)
+
+ def deleteSticky(self, apiclient, id):
+ """Deletes stickyness policy"""
+
+ cmd = deleteLBStickinessPolicy.deleteLBStickinessPolicyCmd()
+ cmd.id = id
+ return apiclient.deleteLBStickinessPolicy(cmd)
+
+ @classmethod
+ def listStickyPolicies(cls, apiclient, lbruleid, **kwargs):
+ """Lists stickiness policies for load balancing rule"""
+
+ cmd = listLBStickinessPolicies.listLBStickinessPoliciesCmd()
+ cmd.lbruleid = lbruleid
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return apiclient.listLBStickinessPolicies(cmd)
+
+ @classmethod
+ def list(cls, apiclient, **kwargs):
+ """List all Load balancing rules matching criteria"""
+
+ cmd = listLoadBalancerRules.listLoadBalancerRulesCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listLoadBalancerRules(cmd))
+
+
+class Cluster:
+ """Manage Cluster life cycle"""
+
+ def __init__(self, items):
+ self.__dict__.update(items)
+
+ @classmethod
+ def create(cls, apiclient, services, zoneid=None, podid=None):
+ """Create Cluster"""
+ cmd = addCluster.addClusterCmd()
+ cmd.clustertype = services["clustertype"]
+ cmd.hypervisor = apiclient.hypervisor
+
+ if zoneid:
+ cmd.zoneid = zoneid
+ else:
+ cmd.zoneid = services["zoneid"]
+
+ if podid:
+ cmd.podid = podid
+ else:
+ cmd.podid = services["podid"]
+
+ if "username" in services:
+ cmd.username = services["username"]
+ if "password" in services:
+ cmd.password = services["password"]
+ if "url" in services:
+ cmd.url = services["url"]
+ if "clustername" in services:
+ cmd.clustername = services["clustername"]
+
+ return Cluster(apiclient.addCluster(cmd)[0].__dict__)
+
+ def delete(self, apiclient):
+ """Delete Cluster"""
+ cmd = deleteCluster.deleteClusterCmd()
+ cmd.id = self.id
+ apiclient.deleteCluster(cmd)
+ return
+
+ @classmethod
+ def list(cls, apiclient, **kwargs):
+ """List all Clusters matching criteria"""
+
+ cmd = listClusters.listClustersCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listClusters(cmd))
+
+
+class Host:
+ """Manage Host life cycle"""
+
+ def __init__(self, items):
+ self.__dict__.update(items)
+
+ @classmethod
+ def create(cls, apiclient, cluster, services, zoneid=None, podid=None):
+ """Create Host in cluster"""
+
+ cmd = addHost.addHostCmd()
+ cmd.hypervisor = apiclient.hypervisor
+ cmd.url = services["url"]
+ cmd.clusterid = cluster.id
+
+ if zoneid:
+ cmd.zoneid = zoneid
+ else:
+ cmd.zoneid = services["zoneid"]
+
+ if podid:
+ cmd.podid = podid
+ else:
+ cmd.podid = services["podid"]
+
+ if "clustertype" in services:
+ cmd.clustertype = services["clustertype"]
+ if "username" in services:
+ cmd.username = services["username"]
+ if "password" in services:
+ cmd.password = services["password"]
+
+ # Add host
+ host = apiclient.addHost(cmd)
+
+ if isinstance(host, list):
+ return Host(host[0].__dict__)
+
+ def delete(self, apiclient):
+ """Delete Host"""
+ # Host must be in maintenance mode before deletion
+ cmd = prepareHostForMaintenance.prepareHostForMaintenanceCmd()
+ cmd.id = self.id
+ apiclient.prepareHostForMaintenance(cmd)
+ time.sleep(30)
+
+ cmd = deleteHost.deleteHostCmd()
+ cmd.id = self.id
+ apiclient.deleteHost(cmd)
+ return
+
+ def enableMaintenance(self, apiclient):
+ """enables maintenance mode Host"""
+
+ cmd = prepareHostForMaintenance.prepareHostForMaintenanceCmd()
+ cmd.id = self.id
+ return apiclient.prepareHostForMaintenance(cmd)
+
+ @classmethod
+ def enableMaintenance(cls, apiclient, id):
+ """enables maintenance mode Host"""
+
+ cmd = prepareHostForMaintenance.prepareHostForMaintenanceCmd()
+ cmd.id = id
+ return apiclient.prepareHostForMaintenance(cmd)
+
+ def cancelMaintenance(self, apiclient):
+ """Cancels maintenance mode Host"""
+
+ cmd = cancelHostMaintenance.cancelHostMaintenanceCmd()
+ cmd.id = self.id
+ return apiclient.cancelHostMaintenance(cmd)
+
+ @classmethod
+ def cancelMaintenance(cls, apiclient, id):
+ """Cancels maintenance mode Host"""
+
+ cmd = cancelHostMaintenance.cancelHostMaintenanceCmd()
+ cmd.id = id
+ return apiclient.cancelHostMaintenance(cmd)
+
+ @classmethod
+ def list(cls, apiclient, **kwargs):
+ """List all Hosts matching criteria"""
+
+ cmd = listHosts.listHostsCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listHosts(cmd))
+
+ @classmethod
+ def listForMigration(cls, apiclient, **kwargs):
+ """List all Hosts for migration matching criteria"""
+
+ cmd = findHostsForMigration.findHostsForMigrationCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.findHostsForMigration(cmd))
+
+ @classmethod
+ def update(cls, apiclient, **kwargs):
+ """Update host information"""
+
+ cmd = updateHost.updateHostCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.updateHost(cmd))
+
+
+class StoragePool:
+ """Manage Storage pools (Primary Storage)"""
+
+ def __init__(self, items):
+ self.__dict__.update(items)
+
+ @classmethod
+ def create(cls, apiclient, services, clusterid=None,
+ zoneid=None, podid=None):
+ """Create Storage pool (Primary Storage)"""
+
+ cmd = createStoragePool.createStoragePoolCmd()
+ cmd.name = services["name"]
+
+ if podid:
+ cmd.podid = podid
+ else:
+ cmd.podid = services["podid"]
+
+ cmd.url = services["url"]
+ if clusterid:
+ cmd.clusterid = clusterid
+ elif "clusterid" in services:
+ cmd.clusterid = services["clusterid"]
+
+ if zoneid:
+ cmd.zoneid = zoneid
+ else:
+ cmd.zoneid = services["zoneid"]
+
+ return StoragePool(apiclient.createStoragePool(cmd).__dict__)
+
+ def delete(self, apiclient):
+ """Delete Storage pool (Primary Storage)"""
+
+ # Storage pool must be in maintenance mode before deletion
+ cmd = enableStorageMaintenance.enableStorageMaintenanceCmd()
+ cmd.id = self.id
+ apiclient.enableStorageMaintenance(cmd)
+ time.sleep(30)
+ cmd = deleteStoragePool.deleteStoragePoolCmd()
+ cmd.id = self.id
+ apiclient.deleteStoragePool(cmd)
+ return
+
+ def enableMaintenance(self, apiclient):
+ """enables maintenance mode Storage pool"""
+
+ cmd = enableStorageMaintenance.enableStorageMaintenanceCmd()
+ cmd.id = self.id
+ return apiclient.enableStorageMaintenance(cmd)
+
+ @classmethod
+ def list(cls, apiclient, **kwargs):
+ """List all storage pools matching criteria"""
+
+ cmd = listStoragePools.listStoragePoolsCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listStoragePools(cmd))
+
+ @classmethod
+ def listForMigration(cls, apiclient, **kwargs):
+ """List all storage pools for migration matching criteria"""
+
+ cmd = findStoragePoolsForMigration.findStoragePoolsForMigrationCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.findStoragePoolsForMigration(cmd))
+
+class Network:
+ """Manage Network pools"""
+
+ def __init__(self, items):
+ self.__dict__.update(items)
+
+ @classmethod
+ def create(cls, apiclient, services, accountid=None, domainid=None,
+ networkofferingid=None, projectid=None,
+ subdomainaccess=None, zoneid=None,
+ gateway=None, netmask=None, vpcid=None, aclid=None):
+ """Create Network for account"""
+ cmd = createNetwork.createNetworkCmd()
+ cmd.name = services["name"]
+ cmd.displaytext = services["displaytext"]
+
+ if networkofferingid:
+ cmd.networkofferingid = networkofferingid
+ elif "networkoffering" in services:
+ cmd.networkofferingid = services["networkoffering"]
+
+ if zoneid:
+ cmd.zoneid = zoneid
+ elif "zoneid" in services:
+ cmd.zoneid = services["zoneid"]
+
+ if subdomainaccess is not None:
+ cmd.subdomainaccess = subdomainaccess
+
+ if gateway:
+ cmd.gateway = gateway
+ elif "gateway" in services:
+ cmd.gateway = services["gateway"]
+ if netmask:
+ cmd.netmask = netmask
+ elif "netmask" in services:
+ cmd.netmask = services["netmask"]
+ if "startip" in services:
+ cmd.startip = services["startip"]
+ if "endip" in services:
+ cmd.endip = services["endip"]
+ if "vlan" in services:
+ cmd.vlan = services["vlan"]
+ if "acltype" in services:
+ cmd.acltype = services["acltype"]
+
+ if accountid:
+ cmd.account = accountid
+ if domainid:
+ cmd.domainid = domainid
+ if projectid:
+ cmd.projectid = projectid
+ if vpcid:
+ cmd.vpcid = vpcid
+ if aclid:
+ cmd.aclid = aclid
+ return Network(apiclient.createNetwork(cmd).__dict__)
+
+ def delete(self, apiclient):
+ """Delete Account"""
+
+ cmd = deleteNetwork.deleteNetworkCmd()
+ cmd.id = self.id
+ apiclient.deleteNetwork(cmd)
+
+ def update(self, apiclient, **kwargs):
+ """Updates network with parameters passed"""
+
+ cmd = updateNetwork.updateNetworkCmd()
+ cmd.id = self.id
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.updateNetwork(cmd))
+
+ def restart(self, apiclient, cleanup=None):
+ """Restarts the network"""
+
+ cmd = restartNetwork.restartNetworkCmd()
+ cmd.id = self.id
+ if cleanup:
+ cmd.cleanup = cleanup
+ return(apiclient.restartNetwork(cmd))
+
+ @classmethod
+ def list(cls, apiclient, **kwargs):
+ """List all Networks matching criteria"""
+
+ cmd = listNetworks.listNetworksCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listNetworks(cmd))
+
+
+class NetworkACL:
+ """Manage Network ACL lifecycle"""
+
+ def __init__(self, items):
+ self.__dict__.update(items)
+
+ @classmethod
+ def create(cls, apiclient, services, networkid=None, protocol=None,
+ number=None, aclid=None, action='Allow', traffictype=None, cidrlist=[]):
+ """Create network ACL rules(Ingress/Egress)"""
+
+ cmd = createNetworkACL.createNetworkACLCmd()
+ if "networkid" in services:
+ cmd.networkid = services["networkid"]
+ elif networkid:
+ cmd.networkid = networkid
+
+ if "protocol" in services:
+ cmd.protocol = services["protocol"]
+ if services["protocol"] == 'ICMP':
+ cmd.icmptype = -1
+ cmd.icmpcode = -1
+ elif protocol:
+ cmd.protocol = protocol
+
+ if "startport" in services:
+ cmd.startport = services["startport"]
+ if "endport" in services:
+ cmd.endport = services["endport"]
+
+ if "cidrlist" in services:
+ cmd.cidrlist = services["cidrlist"]
+ elif cidrlist:
+ cmd.cidrlist = cidrlist
+
+ if "traffictype" in services:
+ cmd.traffictype = services["traffictype"]
+ elif traffictype:
+ cmd.traffictype = traffictype
+
+ if "action" in services:
+ cmd.action = services["action"]
+ elif action:
+ cmd.action = action
+
+ if "number" in services:
+ cmd.number = services["number"]
+ elif number:
+ cmd.number = number
+
+ if "aclid" in services:
+ cmd.aclid = services["aclid"]
+ elif aclid:
+ cmd.aclid = aclid
+
+ # Defaulted to Ingress
+ return NetworkACL(apiclient.createNetworkACL(cmd).__dict__)
+
+ def delete(self, apiclient):
+ """Delete network acl"""
+
+ cmd = deleteNetworkACL.deleteNetworkACLCmd()
+ cmd.id = self.id
+ return apiclient.deleteNetworkACL(cmd)
+
+ @classmethod
+ def list(cls, apiclient, **kwargs):
+ """List Network ACLs"""
+
+ cmd = listNetworkACLs.listNetworkACLsCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listNetworkACLs(cmd))
+
+
+class NetworkACLList:
+ """Manage Network ACL lists lifecycle"""
+
+ def __init__(self, items):
+ self.__dict__.update(items)
+
+ @classmethod
+ def create(cls, apiclient, services, name=None, description=None, vpcid=None):
+ """Create network ACL container list"""
+
+ cmd = createNetworkACLList.createNetworkACLListCmd()
+ if "name" in services:
+ cmd.name = services["name"]
+ elif name:
+ cmd.name = name
+
+ if "description" in services:
+ cmd.description = services["description"]
+ elif description:
+ cmd.description = description
+
+ if "vpcid" in services:
+ cmd.vpcid = services["vpcid"]
+ elif vpcid:
+ cmd.vpcid = vpcid
+
+ return NetworkACLList(apiclient.createNetworkACLList(cmd).__dict__)
+
+ def delete(self, apiclient):
+ """Delete network acl list"""
+
+ cmd = deleteNetworkACLList.deleteNetworkACLListCmd()
+ cmd.id = self.id
+ return apiclient.deleteNetworkACLList(cmd)
+
+ @classmethod
+ def list(cls, apiclient, **kwargs):
+ """List Network ACL lists"""
+
+ cmd = listNetworkACLLists.listNetworkACLListsCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listNetworkACLLists(cmd))
+
+
+class Vpn:
+ """Manage VPN life cycle"""
+
+ def __init__(self, items):
+ self.__dict__.update(items)
+
+ @classmethod
+ def create(cls, apiclient, publicipid, account=None, domainid=None,
+ projectid=None, networkid=None, vpcid=None):
+ """Create VPN for Public IP address"""
+ cmd = createRemoteAccessVpn.createRemoteAccessVpnCmd()
+ cmd.publicipid = publicipid
+ if account:
+ cmd.account = account
+ if domainid:
+ cmd.domainid = domainid
+ if projectid:
+ cmd.projectid = projectid
+ if networkid:
+ cmd.networkid = networkid
+ if vpcid:
+ cmd.vpcid = vpcid
+ return Vpn(apiclient.createRemoteAccessVpn(cmd).__dict__)
+
+ def delete(self, apiclient):
+ """Delete remote VPN access"""
+
+ cmd = deleteRemoteAccessVpn.deleteRemoteAccessVpnCmd()
+ cmd.publicipid = self.publicipid
+ apiclient.deleteRemoteAccessVpn(cmd)
+
+ @classmethod
+ def list(cls, apiclient, **kwargs):
+ """List all VPN matching criteria"""
+
+ cmd = listRemoteAccessVpns.listRemoteAccessVpnsCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listRemoteAccessVpns(cmd))
+
+
+class VpnUser:
+ """Manage VPN user"""
+
+ def __init__(self, items):
+ self.__dict__.update(items)
+
+ @classmethod
+ def create(cls, apiclient, username, password, account=None, domainid=None,
+ projectid=None, rand_name=True):
+ """Create VPN user"""
+ cmd = addVpnUser.addVpnUserCmd()
+ cmd.username = "-".join([username,
+ random_gen()]) if rand_name else username
+ cmd.password = password
+
+ if account:
+ cmd.account = account
+ if domainid:
+ cmd.domainid = domainid
+ if projectid:
+ cmd.projectid = projectid
+ return VpnUser(apiclient.addVpnUser(cmd).__dict__)
+
+ def delete(self, apiclient, projectid=None):
+ """Remove VPN user"""
+
+ cmd = removeVpnUser.removeVpnUserCmd()
+ cmd.username = self.username
+ if projectid:
+ cmd.projectid = projectid
+ else:
+ cmd.account = self.account
+ cmd.domainid = self.domainid
+ apiclient.removeVpnUser(cmd)
+
+ @classmethod
+ def list(cls, apiclient, **kwargs):
+ """List all VPN Users matching criteria"""
+
+ cmd = listVpnUsers.listVpnUsersCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listVpnUsers(cmd))
+
+
+class Zone:
+ """Manage Zone"""
+
+ def __init__(self, items):
+ self.__dict__.update(items)
+
+ @classmethod
+ def create(cls, apiclient, services, domainid=None):
+ """Create zone"""
+ cmd = createZone.createZoneCmd()
+ cmd.dns1 = services["dns1"]
+ cmd.internaldns1 = services["internaldns1"]
+ cmd.name = services["name"]
+ cmd.networktype = services["networktype"]
+
+ if "dns2" in services:
+ cmd.dns2 = services["dns2"]
+ if "internaldns2" in services:
+ cmd.internaldns2 = services["internaldns2"]
+ if domainid:
+ cmd.domainid = domainid
+ if "securitygroupenabled" in services:
+ cmd.securitygroupenabled = services["securitygroupenabled"]
+
+ return Zone(apiclient.createZone(cmd).__dict__)
+
+ def delete(self, apiclient):
+ """Delete Zone"""
+
+ cmd = deleteZone.deleteZoneCmd()
+ cmd.id = self.id
+ apiclient.deleteZone(cmd)
+
+ def update(self, apiclient, **kwargs):
+ """Update the zone"""
+
+ cmd = updateZone.updateZoneCmd()
+ cmd.id = self.id
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return apiclient.updateZone(cmd)
+
+ @classmethod
+ def list(cls, apiclient, **kwargs):
+ """List all Zones matching criteria"""
+
+ cmd = listZones.listZonesCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listZones(cmd))
+
+
+class Pod:
+ """Manage Pod"""
+
+ def __init__(self, items):
+ self.__dict__.update(items)
+
+ @classmethod
+ def create(cls, apiclient, services):
+ """Create Pod"""
+ cmd = createPod.createPodCmd()
+ cmd.gateway = services["gateway"]
+ cmd.netmask = services["netmask"]
+ cmd.name = services["name"]
+ cmd.startip = services["startip"]
+ cmd.endip = services["endip"]
+ cmd.zoneid = services["zoneid"]
+
+ return Pod(apiclient.createPod(cmd).__dict__)
+
+ def delete(self, apiclient):
+ """Delete Pod"""
+
+ cmd = deletePod.deletePodCmd()
+ cmd.id = self.id
+ apiclient.deletePod(cmd)
+
+ @classmethod
+ def list(cls, apiclient, **kwargs):
+ "Returns a default pod for specified zone"
+
+ cmd = listPods.listPodsCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return apiclient.listPods(cmd)
+
+
+class PublicIpRange:
+ """Manage VlanIpRange"""
+
+ def __init__(self, items):
+ self.__dict__.update(items)
+
+ @classmethod
+ def create(cls, apiclient, services):
+ """Create VlanIpRange"""
+
+ cmd = createVlanIpRange.createVlanIpRangeCmd()
+ cmd.gateway = services["gateway"]
+ cmd.netmask = services["netmask"]
+ cmd.forvirtualnetwork = services["forvirtualnetwork"]
+ cmd.startip = services["startip"]
+ cmd.endip = services["endip"]
+ cmd.zoneid = services["zoneid"]
+ cmd.podid = services["podid"]
+ cmd.vlan = services["vlan"]
+
+ return PublicIpRange(apiclient.createVlanIpRange(cmd).__dict__)
+
+ def delete(self, apiclient):
+ """Delete VlanIpRange"""
+
+ cmd = deleteVlanIpRange.deleteVlanIpRangeCmd()
+ cmd.id = self.vlan.id
+ apiclient.deleteVlanIpRange(cmd)
+
+ @classmethod
+ def list(cls, apiclient, **kwargs):
+ """Lists all VLAN IP ranges."""
+
+ cmd = listVlanIpRanges.listVlanIpRangesCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listVlanIpRanges(cmd))
+
+ @classmethod
+ def dedicate(cls, apiclient, id, account=None, domainid=None, projectid=None):
+ """Dedicate VLAN IP range"""
+
+ cmd = dedicatePublicIpRange.dedicatePublicIpRangeCmd()
+ cmd.id = id
+ cmd.account = account
+ cmd.domainid = domainid
+ cmd.projectid = projectid
+ return PublicIpRange(apiclient.dedicatePublicIpRange(cmd).__dict__)
+
+ def release(self, apiclient):
+ """Release VLAN IP range"""
+
+ cmd = releasePublicIpRange.releasePublicIpRangeCmd()
+ cmd.id = self.vlan.id
+ return apiclient.releasePublicIpRange(cmd)
+
+
+class PortablePublicIpRange:
+ """Manage portable public Ip Range"""
+
+ def __init__(self, items):
+ self.__dict__.update(items)
+
+ @classmethod
+ def create(cls, apiclient, services):
+ """Create portable public Ip Range"""
+
+ cmd = createPortableIpRange.createPortableIpRangeCmd()
+ cmd.gateway = services["gateway"]
+ cmd.netmask = services["netmask"]
+ cmd.startip = services["startip"]
+ cmd.endip = services["endip"]
+ cmd.regionid = services["regionid"]
+
+ if "vlan" in services:
+ cmd.vlan = services["vlan"]
+
+ return PortablePublicIpRange(apiclient.createPortableIpRange(cmd).__dict__)
+
+ def delete(self, apiclient):
+ """Delete portable IpRange"""
+
+ cmd = deletePortableIpRange.deletePortableIpRangeCmd()
+ cmd.id = self.id
+ apiclient.deletePortableIpRange(cmd)
+
+ @classmethod
+ def list(cls, apiclient, **kwargs):
+ """Lists all portable public IP ranges."""
+
+ cmd = listPortableIpRanges.listPortableIpRangesCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listPortableIpRanges(cmd))
+
+class SecondaryStagingStore:
+ """Manage Staging Store"""
+
+ def __init__(self, items):
+ self.__dict__.update(items)
+
+ @classmethod
+ def create(cls, apiclient, url, provider, services=None):
+ """Create Staging Storage"""
+ cmd = createSecondaryStagingStore.createSecondaryStagingStoreCmd()
+ cmd.url = url
+ cmd.provider = provider
+ if services:
+ if "zoneid" in services:
+ cmd.zoneid = services["zoneid"]
+ if "details" in services:
+ cmd.details = services["details"]
+ if "scope" in services:
+ cmd.scope = services["scope"]
+
+ return SecondaryStagingStore(apiclient.createSecondaryStagingStore(cmd).__dict__)
+
+ def delete(self, apiclient):
+ """Delete Staging Storage"""
+ cmd = deleteSecondaryStagingStore.deleteSecondaryStagingStoreCmd()
+ cmd.id = self.id
+ apiclient.deleteSecondaryStagingStore(cmd)
+
+ @classmethod
+ def list(cls, apiclient, **kwargs):
+ cmd = listSecondaryStagingStores.listSecondaryStagingStoresCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listSecondaryStagingStores(cmd))
+
+
+class ImageStore:
+ """Manage image stores"""
+
+ def __init__(self, items):
+ self.__dict__.update(items)
+
+ @classmethod
+ def create(cls, apiclient, url, provider, services=None):
+ """Add Image Store"""
+ cmd = addImageStore.addImageStoreCmd()
+ cmd.url = url
+ cmd.provider = provider
+ if services:
+ if "zoneid" in services:
+ cmd.zoneid = services["zoneid"]
+ if "details" in services:
+ cmd.details = services["details"]
+ if "scope" in services:
+ cmd.scope = services["scope"]
+
+ return ImageStore(apiclient.addImageStore(cmd).__dict__)
+
+ def delete(self, apiclient):
+ """Delete Image Store"""
+ cmd = deleteImageStore.deleteImageStoreCmd()
+ cmd.id = self.id
+ apiclient.deleteImageStore(cmd)
+
+ @classmethod
+ def list(cls, apiclient, **kwargs):
+ cmd = listImageStores.listImageStoresCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listImageStores(cmd))
+
+
+class PhysicalNetwork:
+ """Manage physical network storage"""
+
+ def __init__(self, items):
+ self.__dict__.update(items)
+
+ @classmethod
+ def create(cls, apiclient, services, zoneid, domainid=None):
+ """Create physical network"""
+ cmd = createPhysicalNetwork.createPhysicalNetworkCmd()
+
+ cmd.name = services["name"]
+ cmd.zoneid = zoneid
+ if domainid:
+ cmd.domainid = domainid
+ return PhysicalNetwork(apiclient.createPhysicalNetwork(cmd).__dict__)
+
+ def delete(self, apiclient):
+ """Delete Physical Network"""
+
+ cmd = deletePhysicalNetwork.deletePhysicalNetworkCmd()
+ cmd.id = self.id
+ apiclient.deletePhysicalNetwork(cmd)
+
+ def update(self, apiclient, **kwargs):
+ """Update Physical network state"""
+
+ cmd = updatePhysicalNetwork.updatePhysicalNetworkCmd()
+ cmd.id = self.id
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return apiclient.updatePhysicalNetwork(cmd)
+
+ def addTrafficType(self, apiclient, type):
+ """Add Traffic type to Physical network"""
+
+ cmd = addTrafficType.addTrafficTypeCmd()
+ cmd.physicalnetworkid = self.id
+ cmd.traffictype = type
+ return apiclient.addTrafficType(cmd)
+
+ @classmethod
+ def dedicate(cls, apiclient, vlanrange, physicalnetworkid, account=None, domainid=None, projectid=None):
+ """Dedicate guest vlan range"""
+
+ cmd = dedicateGuestVlanRange.dedicateGuestVlanRangeCmd()
+ cmd.vlanrange = vlanrange
+ cmd.physicalnetworkid = physicalnetworkid
+ cmd.account = account
+ cmd.domainid = domainid
+ cmd.projectid = projectid
+ return PhysicalNetwork(apiclient.dedicateGuestVlanRange(cmd).__dict__)
+
+ def release(self, apiclient):
+ """Release guest vlan range"""
+
+ cmd = releaseDedicatedGuestVlanRange.releaseDedicatedGuestVlanRangeCmd()
+ cmd.id = self.id
+ return apiclient.releaseDedicatedGuestVlanRange(cmd)
+
+ @classmethod
+ def listDedicated(cls, apiclient, **kwargs):
+ """Lists all dedicated guest vlan ranges"""
+
+ cmd = listDedicatedGuestVlanRanges.listDedicatedGuestVlanRangesCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return apiclient.listDedicatedGuestVlanRanges(cmd)
+
+ @classmethod
+ def list(cls, apiclient, **kwargs):
+ """Lists all physical networks"""
+
+ cmd = listPhysicalNetworks.listPhysicalNetworksCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return map(lambda pn : PhysicalNetwork(pn.__dict__), apiclient.listPhysicalNetworks(cmd))
+
+
+class SecurityGroup:
+ """Manage Security Groups"""
+
+ def __init__(self, items):
+ self.__dict__.update(items)
+
+ @classmethod
+ def create(cls, apiclient, services, account=None, domainid=None,
+ description=None, projectid=None):
+ """Create security group"""
+ cmd = createSecurityGroup.createSecurityGroupCmd()
+
+ cmd.name = services["name"]
+ if account:
+ cmd.account = account
+ if domainid:
+ cmd.domainid = domainid
+ if description:
+ cmd.description = description
+ if projectid:
+ cmd.projectid = projectid
+
+ return SecurityGroup(apiclient.createSecurityGroup(cmd).__dict__)
+
+ def delete(self, apiclient):
+ """Delete Security Group"""
+
+ cmd = deleteSecurityGroup.deleteSecurityGroupCmd()
+ cmd.id = self.id
+ apiclient.deleteSecurityGroup(cmd)
+
+ def authorize(self, apiclient, services,
+ account=None, domainid=None, projectid=None):
+ """Authorize Ingress Rule"""
+
+ cmd = authorizeSecurityGroupIngress.authorizeSecurityGroupIngressCmd()
+
+ if domainid:
+ cmd.domainid = domainid
+ if account:
+ cmd.account = account
+
+ if projectid:
+ cmd.projectid = projectid
+ cmd.securitygroupid = self.id
+ cmd.protocol = services["protocol"]
+
+ if services["protocol"] == 'ICMP':
+ cmd.icmptype = -1
+ cmd.icmpcode = -1
+ else:
+ cmd.startport = services["startport"]
+ cmd.endport = services["endport"]
+
+ cmd.cidrlist = services["cidrlist"]
+ return (apiclient.authorizeSecurityGroupIngress(cmd).__dict__)
+
+ def revoke(self, apiclient, id):
+ """Revoke in
<TRUNCATED>
[5/6] CLOUDSTACK-6006: Remove integration folder and lib
Posted by gi...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/component/test_vm_passwdenabled.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_vm_passwdenabled.py b/test/integration/component/test_vm_passwdenabled.py
index 5cfa525..038edc1 100644
--- a/test/integration/component/test_vm_passwdenabled.py
+++ b/test/integration/component/test_vm_passwdenabled.py
@@ -18,9 +18,9 @@ import marvin
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
from marvin.sshClient import SshClient
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from nose.plugins.attrib import attr
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/component/test_vmware_drs.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_vmware_drs.py b/test/integration/component/test_vmware_drs.py
index 6a99911..cc0d278 100644
--- a/test/integration/component/test_vmware_drs.py
+++ b/test/integration/component/test_vmware_drs.py
@@ -23,19 +23,19 @@ from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import cloudstackTestCase, unittest
-from marvin.integration.lib.base import (Account,
+from marvin.lib.base import (Account,
AffinityGroup,
Host,
VirtualMachine,
ServiceOffering)
-from marvin.integration.lib.common import (get_zone,
+from marvin.lib.common import (get_zone,
get_template,
get_domain,
get_pod
)
-from marvin.integration.lib.utils import (validateList,
+from marvin.lib.utils import (validateList,
cleanup_resources,
random_gen)
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/component/test_volumes.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_volumes.py b/test/integration/component/test_volumes.py
index ee0f91d..a501da7 100644
--- a/test/integration/component/test_volumes.py
+++ b/test/integration/component/test_volumes.py
@@ -20,9 +20,9 @@
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
#Import System modules
import time
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/component/test_vpc.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_vpc.py b/test/integration/component/test_vpc.py
index ab3b5ab..fa72135 100644
--- a/test/integration/component/test_vpc.py
+++ b/test/integration/component/test_vpc.py
@@ -22,9 +22,9 @@ from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import *
from marvin.cloudstackException import cloudstackAPIException
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
class Services:
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/component/test_vpc_network.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_vpc_network.py b/test/integration/component/test_vpc_network.py
index c393401..d827366 100644
--- a/test/integration/component/test_vpc_network.py
+++ b/test/integration/component/test_vpc_network.py
@@ -21,8 +21,8 @@
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import cloudstackTestCase, unittest
from marvin.cloudstackAPI import startVirtualMachine, stopVirtualMachine
-from marvin.integration.lib.utils import cleanup_resources, validateList
-from marvin.integration.lib.base import (VirtualMachine,
+from marvin.lib.utils import cleanup_resources, validateList
+from marvin.lib.base import (VirtualMachine,
ServiceOffering,
Account,
NATRule,
@@ -35,7 +35,7 @@ from marvin.integration.lib.base import (VirtualMachine,
StaticNATRule,
NetworkACL,
PublicIPAddress)
-from marvin.integration.lib.common import (get_zone,
+from marvin.lib.common import (get_zone,
get_domain,
get_template,
wait_for_cleanup,
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/component/test_vpc_network_lbrules.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_vpc_network_lbrules.py b/test/integration/component/test_vpc_network_lbrules.py
index d623fb9..d411c63 100644
--- a/test/integration/component/test_vpc_network_lbrules.py
+++ b/test/integration/component/test_vpc_network_lbrules.py
@@ -20,7 +20,7 @@
#Import Local Modules
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import cloudstackTestCase, unittest
-from marvin.integration.lib.base import (stopRouter,
+from marvin.lib.base import (stopRouter,
startRouter,
Account,
VpcOffering,
@@ -34,11 +34,11 @@ from marvin.integration.lib.base import (stopRouter,
VirtualMachine,
LoadBalancerRule,
StaticNATRule)
-from marvin.integration.lib.common import (get_domain,
+from marvin.lib.common import (get_domain,
get_zone,
get_template,
list_routers)
-from marvin.integration.lib.utils import cleanup_resources
+from marvin.lib.utils import cleanup_resources
import socket
import time
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/component/test_vpc_network_pfrules.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_vpc_network_pfrules.py b/test/integration/component/test_vpc_network_pfrules.py
index c65da41..ebeffaa 100644
--- a/test/integration/component/test_vpc_network_pfrules.py
+++ b/test/integration/component/test_vpc_network_pfrules.py
@@ -19,7 +19,7 @@
"""
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import cloudstackTestCase, unittest
-from marvin.integration.lib.base import (stopRouter,
+from marvin.lib.base import (stopRouter,
startRouter,
Account,
VpcOffering,
@@ -32,11 +32,11 @@ from marvin.integration.lib.base import (stopRouter,
Network,
VirtualMachine,
LoadBalancerRule)
-from marvin.integration.lib.common import (get_domain,
+from marvin.lib.common import (get_domain,
get_zone,
get_template,
list_routers)
-from marvin.integration.lib.utils import cleanup_resources
+from marvin.lib.utils import cleanup_resources
import socket
import time
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/component/test_vpc_network_staticnatrule.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_vpc_network_staticnatrule.py b/test/integration/component/test_vpc_network_staticnatrule.py
index 46e3479..5733bf9 100644
--- a/test/integration/component/test_vpc_network_staticnatrule.py
+++ b/test/integration/component/test_vpc_network_staticnatrule.py
@@ -19,7 +19,7 @@
"""
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import cloudstackTestCase, unittest
-from marvin.integration.lib.base import (Account,
+from marvin.lib.base import (Account,
VpcOffering,
VPC,
ServiceOffering,
@@ -32,11 +32,11 @@ from marvin.integration.lib.base import (Account,
StaticNATRule)
from marvin.cloudstackAPI import (stopRouter,
startRouter)
-from marvin.integration.lib.common import (get_domain,
+from marvin.lib.common import (get_domain,
get_zone,
get_template,
list_routers)
-from marvin.integration.lib.utils import cleanup_resources
+from marvin.lib.utils import cleanup_resources
import socket
import time
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/component/test_vpc_offerings.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_vpc_offerings.py b/test/integration/component/test_vpc_offerings.py
index 699cef9..36694b1 100644
--- a/test/integration/component/test_vpc_offerings.py
+++ b/test/integration/component/test_vpc_offerings.py
@@ -23,9 +23,9 @@ import marvin
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from marvin.sshClient import SshClient
import datetime
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/component/test_vpc_routers.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_vpc_routers.py b/test/integration/component/test_vpc_routers.py
index a836627..bb10bff 100644
--- a/test/integration/component/test_vpc_routers.py
+++ b/test/integration/component/test_vpc_routers.py
@@ -22,9 +22,9 @@ import marvin
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
import datetime
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/component/test_vpc_vm_life_cycle.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_vpc_vm_life_cycle.py b/test/integration/component/test_vpc_vm_life_cycle.py
index 01373ac..2235983 100644
--- a/test/integration/component/test_vpc_vm_life_cycle.py
+++ b/test/integration/component/test_vpc_vm_life_cycle.py
@@ -20,8 +20,8 @@
#Import Local Modules
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import cloudstackTestCase, unittest
-from marvin.integration.lib.utils import cleanup_resources, validateList
-from marvin.integration.lib.base import (VirtualMachine,
+from marvin.lib.utils import cleanup_resources, validateList
+from marvin.lib.base import (VirtualMachine,
NATRule,
LoadBalancerRule,
StaticNATRule,
@@ -35,7 +35,7 @@ from marvin.integration.lib.base import (VirtualMachine,
Account,
ServiceOffering,
Host)
-from marvin.integration.lib.common import (get_domain,
+from marvin.lib.common import (get_domain,
get_zone,
get_template,
get_free_vlan,
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/component/test_vpc_vms_deployment.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_vpc_vms_deployment.py b/test/integration/component/test_vpc_vms_deployment.py
index 0a244ab..ce3d9e7 100644
--- a/test/integration/component/test_vpc_vms_deployment.py
+++ b/test/integration/component/test_vpc_vms_deployment.py
@@ -20,7 +20,7 @@
#Import Local Modules
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import cloudstackTestCase, unittest
-from marvin.integration.lib.base import (VirtualMachine,
+from marvin.lib.base import (VirtualMachine,
NetworkOffering,
VpcOffering,
VPC,
@@ -36,13 +36,13 @@ from marvin.integration.lib.base import (VirtualMachine,
StaticNATRule,
Configurations)
-from marvin.integration.lib.common import (get_domain,
+from marvin.lib.common import (get_domain,
get_zone,
get_template,
wait_for_cleanup,
get_free_vlan)
-from marvin.integration.lib.utils import cleanup_resources
+from marvin.lib.utils import cleanup_resources
from marvin.cloudstackAPI import rebootRouter
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/component/test_vpn_users.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_vpn_users.py b/test/integration/component/test_vpn_users.py
index d76cbf8..4306d30 100644
--- a/test/integration/component/test_vpn_users.py
+++ b/test/integration/component/test_vpn_users.py
@@ -21,7 +21,7 @@
from nose.plugins.attrib import attr
from marvin.cloudstackException import cloudstackAPIException
from marvin.cloudstackTestCase import cloudstackTestCase
-from marvin.integration.lib.base import (
+from marvin.lib.base import (
Account,
ServiceOffering,
VirtualMachine,
@@ -31,11 +31,11 @@ from marvin.integration.lib.base import (
Configurations,
NATRule
)
-from marvin.integration.lib.common import (get_domain,
+from marvin.lib.common import (get_domain,
get_zone,
get_template
)
-from marvin.integration.lib.utils import cleanup_resources
+from marvin.lib.utils import cleanup_resources
class Services:
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/smoke/test_affinity_groups.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_affinity_groups.py b/test/integration/smoke/test_affinity_groups.py
index b9f0049..dab60b1 100644
--- a/test/integration/smoke/test_affinity_groups.py
+++ b/test/integration/smoke/test_affinity_groups.py
@@ -18,9 +18,9 @@
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from marvin.sshClient import SshClient
from nose.plugins.attrib import attr
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/smoke/test_deploy_vm.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_deploy_vm.py b/test/integration/smoke/test_deploy_vm.py
index 913e5d3..9b28186 100644
--- a/test/integration/smoke/test_deploy_vm.py
+++ b/test/integration/smoke/test_deploy_vm.py
@@ -23,13 +23,13 @@ from marvin.cloudstackTestCase import cloudstackTestCase
#Import Integration Libraries
#base - contains all resources as entities and defines create, delete, list operations on them
-from marvin.integration.lib.base import Account, VirtualMachine, ServiceOffering
+from marvin.lib.base import Account, VirtualMachine, ServiceOffering
#utils - utility classes for common cleanup, external library wrappers etc
-from marvin.integration.lib.utils import cleanup_resources
+from marvin.lib.utils import cleanup_resources
#common - commonly used methods for all tests are listed here
-from marvin.integration.lib.common import get_zone, get_domain, get_template
+from marvin.lib.common import get_zone, get_domain, get_template
from nose.plugins.attrib import attr
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/smoke/test_deploy_vm_with_userdata.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_deploy_vm_with_userdata.py b/test/integration/smoke/test_deploy_vm_with_userdata.py
index 718f65b..27dce50 100644
--- a/test/integration/smoke/test_deploy_vm_with_userdata.py
+++ b/test/integration/smoke/test_deploy_vm_with_userdata.py
@@ -16,11 +16,11 @@
# under the License.
from marvin.cloudstackTestCase import cloudstackTestCase
-from marvin.integration.lib.base import (ServiceOffering,
+from marvin.lib.base import (ServiceOffering,
VirtualMachine,
Account)
-from marvin.integration.lib.common import get_template, get_zone, list_virtual_machines
-from marvin.integration.lib.utils import cleanup_resources
+from marvin.lib.common import get_template, get_zone, list_virtual_machines
+from marvin.lib.utils import cleanup_resources
from nose.plugins.attrib import attr
import random
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/smoke/test_deploy_vms_with_varied_deploymentplanners.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_deploy_vms_with_varied_deploymentplanners.py b/test/integration/smoke/test_deploy_vms_with_varied_deploymentplanners.py
index 475ef95..270d9d2 100644
--- a/test/integration/smoke/test_deploy_vms_with_varied_deploymentplanners.py
+++ b/test/integration/smoke/test_deploy_vms_with_varied_deploymentplanners.py
@@ -16,9 +16,9 @@
# under the License.
from marvin.cloudstackTestCase import cloudstackTestCase
-from marvin.integration.lib.base import Account, VirtualMachine, ServiceOffering, Host, Cluster
-from marvin.integration.lib.common import get_zone, get_domain, get_template
-from marvin.integration.lib.utils import cleanup_resources
+from marvin.lib.base import Account, VirtualMachine, ServiceOffering, Host, Cluster
+from marvin.lib.common import get_zone, get_domain, get_template
+from marvin.lib.utils import cleanup_resources
from nose.plugins.attrib import attr
class TestDeployVmWithVariedPlanners(cloudstackTestCase):
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/smoke/test_disk_offerings.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_disk_offerings.py b/test/integration/smoke/test_disk_offerings.py
index d2d3b4d..9508971 100644
--- a/test/integration/smoke/test_disk_offerings.py
+++ b/test/integration/smoke/test_disk_offerings.py
@@ -20,9 +20,9 @@
import marvin
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from nose.plugins.attrib import attr
_multiprocess_shared_ = True
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/smoke/test_global_settings.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_global_settings.py b/test/integration/smoke/test_global_settings.py
index 5cd3654..89db1af 100644
--- a/test/integration/smoke/test_global_settings.py
+++ b/test/integration/smoke/test_global_settings.py
@@ -19,9 +19,9 @@
#Import Local Modules
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from nose.plugins.attrib import attr
#Import System modules
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/smoke/test_guest_vlan_range.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_guest_vlan_range.py b/test/integration/smoke/test_guest_vlan_range.py
index fb5f170..886d1b8 100644
--- a/test/integration/smoke/test_guest_vlan_range.py
+++ b/test/integration/smoke/test_guest_vlan_range.py
@@ -21,9 +21,9 @@ import marvin
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
import datetime
class TestDedicateGuestVlanRange(cloudstackTestCase):
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/smoke/test_hosts.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_hosts.py b/test/integration/smoke/test_hosts.py
index 375529a..57c35f5 100644
--- a/test/integration/smoke/test_hosts.py
+++ b/test/integration/smoke/test_hosts.py
@@ -20,9 +20,9 @@
import marvin
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from nose.plugins.attrib import attr
#Import System modules
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/smoke/test_internal_lb.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_internal_lb.py b/test/integration/smoke/test_internal_lb.py
index c69d96a..5a9127b 100644
--- a/test/integration/smoke/test_internal_lb.py
+++ b/test/integration/smoke/test_internal_lb.py
@@ -19,9 +19,9 @@
#Import Local Modules
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from nose.plugins.attrib import attr
class TestInternalLb(cloudstackTestCase):
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/smoke/test_iso.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_iso.py b/test/integration/smoke/test_iso.py
index 4e4db2b..0aec94c 100644
--- a/test/integration/smoke/test_iso.py
+++ b/test/integration/smoke/test_iso.py
@@ -20,9 +20,9 @@
import marvin
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from nose.plugins.attrib import attr
import urllib
from random import random
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/smoke/test_loadbalance.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_loadbalance.py b/test/integration/smoke/test_loadbalance.py
index 7bcf1d0..c9fe2e0 100644
--- a/test/integration/smoke/test_loadbalance.py
+++ b/test/integration/smoke/test_loadbalance.py
@@ -18,9 +18,9 @@
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
from marvin.sshClient import SshClient
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from nose.plugins.attrib import attr
#Import System modules
import time
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/smoke/test_multipleips_per_nic.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_multipleips_per_nic.py b/test/integration/smoke/test_multipleips_per_nic.py
index 6eb2d29..8acf285 100644
--- a/test/integration/smoke/test_multipleips_per_nic.py
+++ b/test/integration/smoke/test_multipleips_per_nic.py
@@ -23,13 +23,13 @@ from marvin.cloudstackTestCase import cloudstackTestCase
#Import Integration Libraries
#base - contains all resources as entities and defines create, delete, list operations on them
-from marvin.integration.lib.base import Account, VirtualMachine, ServiceOffering
+from marvin.lib.base import Account, VirtualMachine, ServiceOffering
#utils - utility classes for common cleanup, external library wrappers etc
-from marvin.integration.lib.utils import cleanup_resources
+from marvin.lib.utils import cleanup_resources
#common - commonly used methods for all tests are listed here
-from marvin.integration.lib.common import get_zone, get_domain, get_template
+from marvin.lib.common import get_zone, get_domain, get_template
from marvin.cloudstackAPI.addIpToNic import addIpToNicCmd
from marvin.cloudstackAPI.removeIpFromNic import removeIpFromNicCmd
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/smoke/test_network.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_network.py b/test/integration/smoke/test_network.py
index ad7bf15..566bd37 100644
--- a/test/integration/smoke/test_network.py
+++ b/test/integration/smoke/test_network.py
@@ -22,9 +22,9 @@ from marvin.cloudstackException import CloudstackAPIException
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
from marvin.sshClient import SshClient
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from nose.plugins.attrib import attr
#Import System modules
import time
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/smoke/test_network_acl.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_network_acl.py b/test/integration/smoke/test_network_acl.py
index ce6d78b..50bbbf3 100644
--- a/test/integration/smoke/test_network_acl.py
+++ b/test/integration/smoke/test_network_acl.py
@@ -19,9 +19,9 @@
#Import Local Modules
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from nose.plugins.attrib import attr
class TestNetworkACL(cloudstackTestCase):
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/smoke/test_nic.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_nic.py b/test/integration/smoke/test_nic.py
index 9541eac..4ee43b5 100644
--- a/test/integration/smoke/test_nic.py
+++ b/test/integration/smoke/test_nic.py
@@ -19,9 +19,9 @@ import marvin
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
from marvin.sshClient import SshClient
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from nose.plugins.attrib import attr
import signal
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/smoke/test_non_contigiousvlan.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_non_contigiousvlan.py b/test/integration/smoke/test_non_contigiousvlan.py
index f1736ae..d02948d 100644
--- a/test/integration/smoke/test_non_contigiousvlan.py
+++ b/test/integration/smoke/test_non_contigiousvlan.py
@@ -18,8 +18,8 @@
from marvin import cloudstackTestCase
from marvin.cloudstackAPI import *
from marvin.cloudstackTestCase import cloudstackTestCase
-from marvin.integration.lib.base import Account
-from marvin.integration.lib.base import PhysicalNetwork
+from marvin.lib.base import Account
+from marvin.lib.base import PhysicalNetwork
from nose.plugins.attrib import attr
class Services():
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/smoke/test_portable_publicip.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_portable_publicip.py b/test/integration/smoke/test_portable_publicip.py
index 20d2150..37aaada 100644
--- a/test/integration/smoke/test_portable_publicip.py
+++ b/test/integration/smoke/test_portable_publicip.py
@@ -18,9 +18,9 @@
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from nose.plugins.attrib import attr
class TestPortablePublicIPRange(cloudstackTestCase):
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/smoke/test_primary_storage.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_primary_storage.py b/test/integration/smoke/test_primary_storage.py
index c719f0d..9437b3d 100644
--- a/test/integration/smoke/test_primary_storage.py
+++ b/test/integration/smoke/test_primary_storage.py
@@ -20,9 +20,9 @@
import marvin
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from nose.plugins.attrib import attr
#Import System modules
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/smoke/test_privategw_acl.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_privategw_acl.py b/test/integration/smoke/test_privategw_acl.py
index 9c37e5e..31d0bb1 100644
--- a/test/integration/smoke/test_privategw_acl.py
+++ b/test/integration/smoke/test_privategw_acl.py
@@ -19,9 +19,9 @@
#Import Local Modules
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from nose.plugins.attrib import attr
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/smoke/test_public_ip_range.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_public_ip_range.py b/test/integration/smoke/test_public_ip_range.py
index 672da32..998bda2 100644
--- a/test/integration/smoke/test_public_ip_range.py
+++ b/test/integration/smoke/test_public_ip_range.py
@@ -21,9 +21,9 @@ import marvin
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
import datetime
class TestDedicatePublicIPRange(cloudstackTestCase):
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/smoke/test_pvlan.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_pvlan.py b/test/integration/smoke/test_pvlan.py
index aeb47f9..60f8fd4 100644
--- a/test/integration/smoke/test_pvlan.py
+++ b/test/integration/smoke/test_pvlan.py
@@ -21,9 +21,9 @@ import marvin
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
from marvin.sshClient import SshClient
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from nose.plugins.attrib import attr
import telnetlib
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/smoke/test_regions.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_regions.py b/test/integration/smoke/test_regions.py
index 259cc41..5a3b212 100644
--- a/test/integration/smoke/test_regions.py
+++ b/test/integration/smoke/test_regions.py
@@ -17,9 +17,9 @@
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from nose.plugins.attrib import attr
class TestRegions(cloudstackTestCase):
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/smoke/test_reset_vm_on_reboot.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_reset_vm_on_reboot.py b/test/integration/smoke/test_reset_vm_on_reboot.py
index 96d8ac2..fac96fa 100644
--- a/test/integration/smoke/test_reset_vm_on_reboot.py
+++ b/test/integration/smoke/test_reset_vm_on_reboot.py
@@ -20,9 +20,9 @@
import marvin
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from nose.plugins.attrib import attr
_multiprocess_shared_ = True
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/smoke/test_resource_detail.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_resource_detail.py b/test/integration/smoke/test_resource_detail.py
index 7fb3bd4..e7081f7 100644
--- a/test/integration/smoke/test_resource_detail.py
+++ b/test/integration/smoke/test_resource_detail.py
@@ -21,9 +21,9 @@ import marvin
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
from marvin.sshClient import SshClient
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from nose.plugins.attrib import attr
#Import System modules
import time
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/smoke/test_routers.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_routers.py b/test/integration/smoke/test_routers.py
index 4e7a873..61dc5be 100644
--- a/test/integration/smoke/test_routers.py
+++ b/test/integration/smoke/test_routers.py
@@ -21,9 +21,9 @@ import marvin
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
from marvin.sshClient import SshClient
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from nose.plugins.attrib import attr
#Import System modules
import time
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/smoke/test_scale_vm.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_scale_vm.py b/test/integration/smoke/test_scale_vm.py
index 7507b8f..6fa8d77 100644
--- a/test/integration/smoke/test_scale_vm.py
+++ b/test/integration/smoke/test_scale_vm.py
@@ -20,9 +20,9 @@
import marvin
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from nose.plugins.attrib import attr
_multiprocess_shared_ = True
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/smoke/test_secondary_storage.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_secondary_storage.py b/test/integration/smoke/test_secondary_storage.py
index 423f858..d430beb 100644
--- a/test/integration/smoke/test_secondary_storage.py
+++ b/test/integration/smoke/test_secondary_storage.py
@@ -20,9 +20,9 @@
import marvin
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from nose.plugins.attrib import attr
#Import System modules
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/smoke/test_service_offerings.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_service_offerings.py b/test/integration/smoke/test_service_offerings.py
index 916f9f2..b518c98 100644
--- a/test/integration/smoke/test_service_offerings.py
+++ b/test/integration/smoke/test_service_offerings.py
@@ -19,13 +19,13 @@
#Import Local Modules
from marvin.cloudstackTestCase import cloudstackTestCase
from marvin.cloudstackAPI import changeServiceForVirtualMachine,updateServiceOffering
-from marvin.integration.lib.utils import (isAlmostEqual,
+from marvin.lib.utils import (isAlmostEqual,
cleanup_resources,
random_gen)
-from marvin.integration.lib.base import (ServiceOffering,
+from marvin.lib.base import (ServiceOffering,
Account,
VirtualMachine)
-from marvin.integration.lib.common import (list_service_offering,
+from marvin.lib.common import (list_service_offering,
list_virtual_machines,
get_domain,
get_zone,
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/smoke/test_snapshots.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_snapshots.py b/test/integration/smoke/test_snapshots.py
index 9777770..312da45 100644
--- a/test/integration/smoke/test_snapshots.py
+++ b/test/integration/smoke/test_snapshots.py
@@ -18,9 +18,9 @@
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
class TestSnapshotRootDisk(cloudstackTestCase):
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/smoke/test_ssvm.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_ssvm.py b/test/integration/smoke/test_ssvm.py
index 4c93031..d8e9f85 100644
--- a/test/integration/smoke/test_ssvm.py
+++ b/test/integration/smoke/test_ssvm.py
@@ -21,9 +21,9 @@ import marvin
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
from marvin.sshClient import SshClient
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from nose.plugins.attrib import attr
import telnetlib
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/smoke/test_templates.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_templates.py b/test/integration/smoke/test_templates.py
index c9a1520..71aee48 100644
--- a/test/integration/smoke/test_templates.py
+++ b/test/integration/smoke/test_templates.py
@@ -21,9 +21,9 @@ import marvin
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
from marvin.sshClient import SshClient
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from nose.plugins.attrib import attr
import urllib
from random import random
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/smoke/test_vm_life_cycle.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_vm_life_cycle.py b/test/integration/smoke/test_vm_life_cycle.py
index f7316b2..31031c8 100644
--- a/test/integration/smoke/test_vm_life_cycle.py
+++ b/test/integration/smoke/test_vm_life_cycle.py
@@ -20,9 +20,9 @@
import marvin
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from nose.plugins.attrib import attr
#Import System modules
import time
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/smoke/test_vm_snapshots.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_vm_snapshots.py b/test/integration/smoke/test_vm_snapshots.py
index 214fe50..86af013 100644
--- a/test/integration/smoke/test_vm_snapshots.py
+++ b/test/integration/smoke/test_vm_snapshots.py
@@ -20,9 +20,9 @@ import marvin
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
class TestVmSnapshot(cloudstackTestCase):
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/smoke/test_volumes.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_volumes.py b/test/integration/smoke/test_volumes.py
index 2d6b2ab..f650dd5 100644
--- a/test/integration/smoke/test_volumes.py
+++ b/test/integration/smoke/test_volumes.py
@@ -22,10 +22,10 @@ from marvin.cloudstackTestCase import *
from marvin.cloudstackException import *
from marvin.cloudstackAPI import *
from marvin.sshClient import SshClient
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
-from marvin.integration.lib.utils import checkVolumeSize
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
+from marvin.lib.utils import checkVolumeSize
from marvin.codes import SUCCESS
from nose.plugins.attrib import attr
#Import System modules
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/test/integration/smoke/test_vpc_vpn.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_vpc_vpn.py b/test/integration/smoke/test_vpc_vpn.py
index c41c2a0..56215c1 100644
--- a/test/integration/smoke/test_vpc_vpn.py
+++ b/test/integration/smoke/test_vpc_vpn.py
@@ -19,9 +19,9 @@
#Import Local Modules
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from nose.plugins.attrib import attr
import time
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/tools/marvin/marvin/cloudstackConnection.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/cloudstackConnection.py b/tools/marvin/marvin/cloudstackConnection.py
index 8413ac0..04e5afb 100644
--- a/tools/marvin/marvin/cloudstackConnection.py
+++ b/tools/marvin/marvin/cloudstackConnection.py
@@ -63,6 +63,7 @@ class CSConnection(object):
self.logger = logger
self.path = path
self.retries = 5
+ self.__lastError = ''
self.mgtDetails = mgmtDet
self.asyncTimeout = asyncTimeout
self.auth = True
@@ -82,8 +83,9 @@ class CSConnection(object):
def __poll(self, jobid, response_cmd):
'''
+ @Name : __poll
@Desc: polls for the completion of a given jobid
- @param 1. jobid: Monitor the Jobid for CS
+ @Input 1. jobid: Monitor the Jobid for CS
2. response_cmd:response command for request cmd
@return: FAILED if jobid is cancelled,failed
Else return async_response
@@ -114,17 +116,25 @@ class CSConnection(object):
str(timeout)))
return FAILED
except Exception, e:
+ self.__lastError = GetDetailExceptionInfo(e)
self.logger.exception("__poll: Exception Occurred :%s" %
- GetDetailExceptionInfo(e))
+ self.__lastError)
return FAILED
+ def getLastError(self):
+ '''
+ @Name : getLastError
+ @Desc : Returns the last error from marvinRequest
+ '''
+ return self.__lastError
+
def __sign(self, payload):
"""
@Name : __sign
@Desc:signs a given request URL when the apiKey and
secretKey are known
- @param payload: dict of GET params to be signed
- @return: the signature of the payload
+ @Input: payload: dictionary of params be signed
+ @Output: the signature of the payload
"""
params = zip(payload.keys(), payload.values())
params.sort(key=lambda k: str.lower(k[0]))
@@ -146,6 +156,8 @@ class CSConnection(object):
@Desc : Sends the POST Request to CS
@Input : url: URL to send post req
payload:Payload information as part of request
+ @Output: Returns response from POST output
+ else FAILED
'''
try:
response = requests.post(url,
@@ -154,9 +166,10 @@ class CSConnection(object):
verify=self.httpsFlag)
return response
except Exception, e:
+ self.__lastError = GetDetailExceptionInfo(e)
self.logger.\
exception("__sendPostReqToCS : Exception "
- "Occurred: %s" % GetDetailExceptionInfo(e))
+ "Occurred: %s" % self.__lastError)
return FAILED
def __sendGetReqToCS(self, url, payload):
@@ -165,6 +178,8 @@ class CSConnection(object):
@Desc : Sends the GET Request to CS
@Input : url: URL to send post req
payload:Payload information as part of request
+ @Output: Returns response from GET output
+ else FAILED
'''
try:
response = requests.get(url,
@@ -173,20 +188,21 @@ class CSConnection(object):
verify=self.httpsFlag)
return response
except Exception, e:
+ self.__lastError = GetDetailExceptionInfo(e)
self.logger.exception("__sendGetReqToCS : Exception Occurred: %s" %
- GetDetailExceptionInfo(e))
+ self.__lastError)
return FAILED
def __sendCmdToCS(self, command, auth=True, payload={}, method='GET'):
"""
@Name : __sendCmdToCS
@Desc : Makes requests to CS using the Inputs provided
- @param command: cloudstack API command name
+ @Input: command: cloudstack API command name
eg: deployVirtualMachineCommand
- @param auth: Authentication (apikey,secretKey) => True
+ auth: Authentication (apikey,secretKey) => True
else False for integration.api.port
- @param payload: request data composed as a dictionary
- @param method: GET/POST via HTTP
+ payload: request data composed as a dictionary
+ method: GET/POST via HTTP
@output: FAILED or else response from CS
"""
try:
@@ -220,9 +236,9 @@ class CSConnection(object):
"""
@Name : __sanitizeCmd
@Desc : Removes None values, Validates all required params are present
- @param cmd: Cmd object eg: createPhysicalNetwork
- @Output: Returns command name, asynchronous or not , request payload
- INVALID_INPUT if cmd is invalid
+ @Input: cmd: Cmd object eg: createPhysicalNetwork
+ @Output: Returns command name, asynchronous or not,request payload
+ FAILED for failed cases
"""
try:
cmd_name = ''
@@ -241,7 +257,7 @@ class CSConnection(object):
if payload[required_param] is None:
self.logger.debug("CmdName: %s Parameter : %s is Required"
% (cmd_name, required_param))
- return INVALID_INPUT
+ return FAILED
for param, value in payload.items():
if value is None:
payload.pop(param)
@@ -272,10 +288,11 @@ class CSConnection(object):
@Name : __parseAndGetResponse
@Desc : Verifies the Response(from CS) and returns an
appropriate json parsed Response
- @Output:
+ @Input: cmd_response: Command Response from cs
+ response_cls : Mapping class for this Response
+ is_async: Whether the cmd is async or not.
+ @Output:Response output from CS
'''
- if cmd_response == FAILED:
- return FAILED
try:
ret = jsonHelper.getResultObj(cmd_response.json(), response_cls)
except TypeError:
@@ -297,10 +314,10 @@ class CSConnection(object):
"""
@Name : marvinRequest
@Desc: Handles Marvin Requests
- @param cmd: marvin's command from cloudstackAPI
- @param response_type: response type of the command in cmd
- @param method: HTTP GET/POST, defaults to GET
- @return: Response received from CS
+ @Input cmd: marvin's command from cloudstackAPI
+ response_type: response type of the command in cmd
+ method: HTTP GET/POST, defaults to GET
+ @Output: Response received from CS
FAILED In case of Error\Exception
"""
try:
@@ -315,13 +332,12 @@ class CSConnection(object):
'''
2. Sanitize the Command
'''
- if self.__sanitizeCmd(cmd) != INVALID_INPUT:
- cmd_name, is_async, payload = self.__sanitizeCmd(cmd)
- else:
- self.logger.exception("marvinRequest : Cmd: "
- "Sanitizing Command Failed")
+ sanitize_cmd_out = self.__sanitizeCmd(cmd)
+
+ if sanitize_cmd_out == FAILED:
return FAILED
+ cmd_name, is_async, payload = sanitize_cmd_out
'''
3. Send Command to CS
'''
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/tools/marvin/marvin/cloudstackTestCase.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/cloudstackTestCase.py b/tools/marvin/marvin/cloudstackTestCase.py
index 6456bb1..303f7ad 100644
--- a/tools/marvin/marvin/cloudstackTestCase.py
+++ b/tools/marvin/marvin/cloudstackTestCase.py
@@ -16,7 +16,7 @@
# under the License.
import unittest
-from marvin.integration.lib.utils import verifyElementInList
+from marvin.lib.utils import verifyElementInList
from marvin.codes import PASS
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/tools/marvin/marvin/cloudstackTestClient.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/cloudstackTestClient.py b/tools/marvin/marvin/cloudstackTestClient.py
index f0ba135..e8c6ab2 100644
--- a/tools/marvin/marvin/cloudstackTestClient.py
+++ b/tools/marvin/marvin/cloudstackTestClient.py
@@ -25,10 +25,9 @@ import hashlib
from codes import (FAILED, PASS, ADMIN, DOMAIN_ADMIN,
USER, SUCCESS, XEN_SERVER)
from configGenerator import ConfigManager
-from marvin.integration.lib import utils
+from marvin.lib import utils
from cloudstackException import GetDetailExceptionInfo
-from marvin.integration.lib.utils import (random_gen,
- validateList)
+from marvin.lib.utils import (random_gen, validateList)
from marvin.cloudstackAPI.cloudstackAPIClient import CloudStackAPIClient
'''
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/tools/marvin/marvin/integration/__init__.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/integration/__init__.py b/tools/marvin/marvin/integration/__init__.py
deleted file mode 100644
index 57823fc..0000000
--- a/tools/marvin/marvin/integration/__init__.py
+++ /dev/null
@@ -1,18 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/tools/marvin/marvin/integration/lib/__init__.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/integration/lib/__init__.py b/tools/marvin/marvin/integration/lib/__init__.py
deleted file mode 100644
index 978b68a..0000000
--- a/tools/marvin/marvin/integration/lib/__init__.py
+++ /dev/null
@@ -1,16 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
[3/6] CLOUDSTACK-6006: Remove integration folder and lib
Posted by gi...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/tools/marvin/marvin/integration/lib/common.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/integration/lib/common.py b/tools/marvin/marvin/integration/lib/common.py
deleted file mode 100644
index 4177b91..0000000
--- a/tools/marvin/marvin/integration/lib/common.py
+++ /dev/null
@@ -1,955 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-"""Common functions
-"""
-
-#Import Local Modules
-from marvin.cloudstackAPI import (listConfigurations,
- listPhysicalNetworks,
- listRegions,
- addNetworkServiceProvider,
- updateNetworkServiceProvider,
- listDomains,
- listZones,
- listPods,
- listOsTypes,
- listTemplates,
- updateResourceLimit,
- listRouters,
- listNetworks,
- listClusters,
- listSystemVms,
- listStoragePools,
- listVirtualMachines,
- listLoadBalancerRuleInstances,
- listFirewallRules,
- listVolumes,
- listIsos,
- listAccounts,
- listSnapshotPolicies,
- listDiskOfferings,
- listVlanIpRanges,
- listUsageRecords,
- listNetworkServiceProviders,
- listHosts,
- listPublicIpAddresses,
- listPortForwardingRules,
- listLoadBalancerRules,
- listSnapshots,
- listUsers,
- listEvents,
- listServiceOfferings,
- listVirtualRouterElements,
- listNetworkOfferings,
- listResourceLimits,
- listVPCOfferings)
-from marvin.integration.lib.base import (Configurations,
- NetScaler,
- Template,
- Resources,
- PhysicalNetwork,
- Host)
-from marvin.integration.lib.utils import (get_process_status,
- xsplit)
-
-from marvin.sshClient import SshClient
-import random
-from utils import *
-from base import *
-from marvin.codes import PASS
-from marvin.integration.lib.utils import validateList
-
-#Import System modules
-import time
-
-
-def is_config_suitable(apiclient, name, value):
- """
- Ensure if the deployment has the expected `value` for the global setting `name'
- @return: true if value is set, else false
- """
- configs = Configurations.list(apiclient, name=name)
- assert(configs is not None and isinstance(configs, list) and len(configs) > 0)
- return configs[0].value == value
-
-def wait_for_cleanup(apiclient, configs=None):
- """Sleeps till the cleanup configs passed"""
-
- # Configs list consists of the list of global configs
- if not isinstance(configs, list):
- return
- for config in configs:
- cmd = listConfigurations.listConfigurationsCmd()
- cmd.name = config
- cmd.listall = True
- try:
- config_descs = apiclient.listConfigurations(cmd)
- except Exception as e:
- raise Exception("Failed to fetch configurations: %s" % e)
-
- if not isinstance(config_descs, list):
- raise Exception("List configs didn't returned a valid data")
-
- config_desc = config_descs[0]
- # Sleep for the config_desc.value time
- time.sleep(int(config_desc.value))
- return
-
-def add_netscaler(apiclient, zoneid, NSservice):
- """ Adds Netscaler device and enables NS provider"""
-
- cmd = listPhysicalNetworks.listPhysicalNetworksCmd()
- cmd.zoneid = zoneid
- physical_networks = apiclient.listPhysicalNetworks(cmd)
- if isinstance(physical_networks, list):
- physical_network = physical_networks[0]
-
- cmd = listNetworkServiceProviders.listNetworkServiceProvidersCmd()
- cmd.name = 'Netscaler'
- cmd.physicalnetworkid=physical_network.id
- nw_service_providers = apiclient.listNetworkServiceProviders(cmd)
-
- if isinstance(nw_service_providers, list):
- netscaler_provider = nw_service_providers[0]
- else:
- cmd1 = addNetworkServiceProvider.addNetworkServiceProviderCmd()
- cmd1.name = 'Netscaler'
- cmd1.physicalnetworkid = physical_network.id
- netscaler_provider = apiclient.addNetworkServiceProvider(cmd1)
-
- netscaler = NetScaler.add(
- apiclient,
- NSservice,
- physicalnetworkid=physical_network.id
- )
- if netscaler_provider.state != 'Enabled':
- cmd = updateNetworkServiceProvider.updateNetworkServiceProviderCmd()
- cmd.id = netscaler_provider.id
- cmd.state = 'Enabled'
- apiclient.updateNetworkServiceProvider(cmd)
-
- return netscaler
-
-def get_region(apiclient, region_id=None, region_name=None):
- '''
- @name : get_region
- @Desc : Returns the Region Information for a given region id or region name
- @Input : region_name: Name of the Region
- region_id : Id of the region
- @Output : 1. Region Information for the passed inputs else first Region
- 2. FAILED In case the cmd failed
- '''
- if region_id is None and region_name is None:
- return FAILED
- cmd = listRegions.listRegionsCmd()
- if region_name is not None:
- cmd.name = region_name
- if region_id is not None:
- cmd.id = region_id
- cmd_out = apiclient.listRegions(cmd)
- return FAILED if validateList(cmd_out)[0] != PASS else cmd_out
-
-
-def get_domain(apiclient, domain_id=None, domain_name=None):
- '''
- @name : get_domain
- @Desc : Returns the Domain Information for a given domain id or domain name
- @Input : domain id : Id of the Domain
- domain_name : Name of the Domain
- @Output : 1. Domain Information for the passed inputs else first Domain
- 2. FAILED In case the cmd failed
- '''
- cmd = listDomains.listDomainsCmd()
-
- if domain_name is not None:
- cmd.name = domain_name
- if domain_id is not None:
- cmd.id = domain_id
- cmd_out = apiclient.listRegions(cmd)
- return FAILED if validateList(cmd_out)[0] != PASS else cmd_out
-
-
-def get_zone(apiclient, zone_name=None, zone_id=None):
- '''
- @name : get_zone
- @Desc :Returns the Zone Information for a given zone id or Zone Name
- @Input : zone_name: Name of the Zone
- zone_id : Id of the zone
- @Output : 1. Zone Information for the passed inputs else first zone
- 2. FAILED In case the cmd failed
- '''
- cmd = listZones.listZonesCmd()
- if zone_name is not None:
- cmd.name = zone_name
- if zone_id is not None:
- cmd.id = zone_id
-
- cmd_out = apiclient.listZones(cmd)
-
- if validateList(cmd_out)[0] != PASS: return FAILED
- '''
- Check if input zone name and zone id is None,
- then return first element of List Zones command
- '''
- if (zone_name is None and zone_id is None):
- return cmd_out[0]
- else:
- return cmd_out
-
-
-
-def get_pod(apiclient, zone_id=None, pod_id=None, pod_name=None):
- '''
- @name : get_pod
- @Desc : Returns the Pod Information for a given zone id or Zone Name
- @Input : zone_id: Id of the Zone
- pod_name : Name of the Pod
- pod_id : Id of the Pod
- @Output : 1. Pod Information for the pod
- 2. FAILED In case the cmd failed
- '''
- cmd = listPods.listPodsCmd()
-
- if pod_name is not None:
- cmd.name = pod_name
- if pod_id is not None:
- cmd.id = pod_id
- if zone_id is not None:
- cmd.zoneid = zone_id
-
- cmd_out = apiclient.listPods(cmd)
-
- return FAILED if (validateList(cmd_out)[0] != PASS) else cmd_out
-
-
-def get_template(apiclient, zone_id=None, ostype_desc=None, template_filter="featured", template_type='BUILTIN',
- template_id=None, template_name=None, account=None, domain_id=None, project_id=None,
- hypervisor=None):
- '''
- @Name : get_template
- @Desc : Retrieves the template Information based upon inputs provided
- Template is retrieved based upon either of the inputs matched
- condition
- @Input : returns a template"
- @Output : FAILED in case of any failure
- template Information matching the inputs
- '''
-
- '''
- Get OS TypeID First based upon ostype_desc
- '''
- cmd = listOsTypes.listOsTypesCmd()
- cmd.description = ostype_desc
- ostypes_out = apiclient.listOsTypes(cmd)
-
- if (validateList(ostypes_out)[0] != PASS): return FAILED
-
- ostype_id = ostypes_out[0].id
-
- listcmd = listTemplates.listTemplatesCmd()
- cmd.templatefilter = template_filter
- if domain_id is not None:
- cmd.domainid = domain_id
- if zone_id is not None:
- cmd.zoneid = zone_id
- if template_id is not None:
- cmd.id = template_id
- if template_name is not None:
- cmd.name = template_name
- if hypervisor is not None:
- cmd.hypervisor = hypervisor
- if project_id is not None:
- cmd.projectid = project_id
- if account is not None:
- cmd.account = account
-
- '''
- Get the Templates pertaining
- '''
- list_templatesout = apiclient.listTemplates(cmd)
- if validateList(list_templatesout)[0] != PASS: return FAILED
-
- for template in list_templatesout:
- if template.ostypeid == ostype_id and template.isready and template.templatetype == template_type:
- return template
- '''
- Return Failed if None of the templates matched
- '''
- return FAILED
-
-def download_systemplates_sec_storage(server, services):
- """Download System templates on sec storage"""
-
- try:
- # Login to management server
- ssh = SshClient(
- server["ipaddress"],
- server["port"],
- server["username"],
- server["password"]
- )
- except Exception:
- raise Exception("SSH access failed for server with IP address: %s" %
- server["ipaddess"])
- # Mount Secondary Storage on Management Server
- cmds = [
- "mkdir -p %s" % services["mnt_dir"],
- "mount -t nfs %s:/%s %s" % (
- services["sec_storage"],
- services["path"],
- services["mnt_dir"]
- ),
- "%s -m %s -u %s -h %s -F" % (
- services["command"],
- services["mnt_dir"],
- services["download_url"],
- services["hypervisor"]
- )
- ]
- for c in cmds:
- result = ssh.execute(c)
-
- res = str(result)
-
- # Unmount the Secondary storage
- ssh.execute("umount %s" % (services["mnt_dir"]))
-
- if res.count("Successfully installed system VM template") == 1:
- return
- else:
- raise Exception("Failed to download System Templates on Sec Storage")
- return
-
-
-def wait_for_ssvms(apiclient, zoneid, podid, interval=60):
- """After setup wait for SSVMs to come Up"""
-
- time.sleep(interval)
- timeout = 40
- while True:
- list_ssvm_response = list_ssvms(
- apiclient,
- systemvmtype='secondarystoragevm',
- zoneid=zoneid,
- podid=podid
- )
- ssvm = list_ssvm_response[0]
- if ssvm.state != 'Running':
- # Sleep to ensure SSVMs are Up and Running
- time.sleep(interval)
- timeout = timeout - 1
- elif ssvm.state == 'Running':
- break
- elif timeout == 0:
- raise Exception("SSVM failed to come up")
- break
-
- timeout = 40
- while True:
- list_ssvm_response = list_ssvms(
- apiclient,
- systemvmtype='consoleproxy',
- zoneid=zoneid,
- podid=podid
- )
- cpvm = list_ssvm_response[0]
- if cpvm.state != 'Running':
- # Sleep to ensure SSVMs are Up and Running
- time.sleep(interval)
- timeout = timeout - 1
- elif cpvm.state == 'Running':
- break
- elif timeout == 0:
- raise Exception("CPVM failed to come up")
- break
- return
-
-def get_builtin_template_info(apiclient, zoneid):
- """Returns hypervisor specific infor for templates"""
-
- list_template_response = Template.list(
- apiclient,
- templatefilter='featured',
- zoneid=zoneid,
- )
-
- for b_template in list_template_response:
- if b_template.templatetype == 'BUILTIN':
- break
-
- extract_response = Template.extract(apiclient,
- b_template.id,
- 'HTTP_DOWNLOAD',
- zoneid)
-
- return extract_response.url, b_template.hypervisor, b_template.format
-
-def download_builtin_templates(apiclient, zoneid, hypervisor, host,
- linklocalip, interval=60):
- """After setup wait till builtin templates are downloaded"""
-
- # Change IPTABLES Rules
- get_process_status(
- host["ipaddress"],
- host["port"],
- host["username"],
- host["password"],
- linklocalip,
- "iptables -P INPUT ACCEPT"
- )
- time.sleep(interval)
- # Find the BUILTIN Templates for given Zone, Hypervisor
- list_template_response = list_templates(
- apiclient,
- hypervisor=hypervisor,
- zoneid=zoneid,
- templatefilter='self'
- )
-
- if not isinstance(list_template_response, list):
- raise Exception("Failed to download BUILTIN templates")
-
- # Ensure all BUILTIN templates are downloaded
- templateid = None
- for template in list_template_response:
- if template.templatetype == "BUILTIN":
- templateid = template.id
-
- # Sleep to ensure that template is in downloading state after adding
- # Sec storage
- time.sleep(interval)
- while True:
- template_response = list_templates(
- apiclient,
- id=templateid,
- zoneid=zoneid,
- templatefilter='self'
- )
- template = template_response[0]
- # If template is ready,
- # template.status = Download Complete
- # Downloading - x% Downloaded
- # Error - Any other string
- if template.status == 'Download Complete':
- break
-
- elif 'Downloaded' in template.status:
- time.sleep(interval)
-
- elif 'Installing' not in template.status:
- raise Exception("ErrorInDownload")
-
- return
-
-
-def update_resource_limit(apiclient, resourcetype, account=None,
- domainid=None, max=None, projectid=None):
- """Updates the resource limit to 'max' for given account"""
-
- cmd = updateResourceLimit.updateResourceLimitCmd()
- cmd.resourcetype = resourcetype
- if account:
- cmd.account = account
- if domainid:
- cmd.domainid = domainid
- if max:
- cmd.max = max
- if projectid:
- cmd.projectid = projectid
- apiclient.updateResourceLimit(cmd)
- return
-
-
-def list_os_types(apiclient, **kwargs):
- """List all os types matching criteria"""
-
- cmd = listOsTypes.listOsTypesCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listOsTypes(cmd))
-
-
-def list_routers(apiclient, **kwargs):
- """List all Routers matching criteria"""
-
- cmd = listRouters.listRoutersCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listRouters(cmd))
-
-
-def list_zones(apiclient, **kwargs):
- """List all Zones matching criteria"""
-
- cmd = listZones.listZonesCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listZones(cmd))
-
-
-def list_networks(apiclient, **kwargs):
- """List all Networks matching criteria"""
-
- cmd = listNetworks.listNetworksCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listNetworks(cmd))
-
-
-def list_clusters(apiclient, **kwargs):
- """List all Clusters matching criteria"""
-
- cmd = listClusters.listClustersCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listClusters(cmd))
-
-
-def list_ssvms(apiclient, **kwargs):
- """List all SSVMs matching criteria"""
-
- cmd = listSystemVms.listSystemVmsCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listSystemVms(cmd))
-
-
-def list_storage_pools(apiclient, **kwargs):
- """List all storage pools matching criteria"""
-
- cmd = listStoragePools.listStoragePoolsCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listStoragePools(cmd))
-
-
-def list_virtual_machines(apiclient, **kwargs):
- """List all VMs matching criteria"""
-
- cmd = listVirtualMachines.listVirtualMachinesCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listVirtualMachines(cmd))
-
-
-def list_hosts(apiclient, **kwargs):
- """List all Hosts matching criteria"""
-
- cmd = listHosts.listHostsCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listHosts(cmd))
-
-
-def list_configurations(apiclient, **kwargs):
- """List configuration with specified name"""
-
- cmd = listConfigurations.listConfigurationsCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listConfigurations(cmd))
-
-
-def list_publicIP(apiclient, **kwargs):
- """List all Public IPs matching criteria"""
-
- cmd = listPublicIpAddresses.listPublicIpAddressesCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listPublicIpAddresses(cmd))
-
-
-def list_nat_rules(apiclient, **kwargs):
- """List all NAT rules matching criteria"""
-
- cmd = listPortForwardingRules.listPortForwardingRulesCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listPortForwardingRules(cmd))
-
-
-def list_lb_rules(apiclient, **kwargs):
- """List all Load balancing rules matching criteria"""
-
- cmd = listLoadBalancerRules.listLoadBalancerRulesCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listLoadBalancerRules(cmd))
-
-
-def list_lb_instances(apiclient, **kwargs):
- """List all Load balancing instances matching criteria"""
-
- cmd = listLoadBalancerRuleInstances.listLoadBalancerRuleInstancesCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listLoadBalancerRuleInstances(cmd))
-
-
-def list_firewall_rules(apiclient, **kwargs):
- """List all Firewall Rules matching criteria"""
-
- cmd = listFirewallRules.listFirewallRulesCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listFirewallRules(cmd))
-
-
-def list_volumes(apiclient, **kwargs):
- """List all volumes matching criteria"""
-
- cmd = listVolumes.listVolumesCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listVolumes(cmd))
-
-
-def list_isos(apiclient, **kwargs):
- """Lists all available ISO files."""
-
- cmd = listIsos.listIsosCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listIsos(cmd))
-
-
-def list_snapshots(apiclient, **kwargs):
- """List all snapshots matching criteria"""
-
- cmd = listSnapshots.listSnapshotsCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listSnapshots(cmd))
-
-
-def list_templates(apiclient, **kwargs):
- """List all templates matching criteria"""
-
- cmd = listTemplates.listTemplatesCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listTemplates(cmd))
-
-
-def list_domains(apiclient, **kwargs):
- """Lists domains"""
-
- cmd = listDomains.listDomainsCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listDomains(cmd))
-
-
-def list_accounts(apiclient, **kwargs):
- """Lists accounts and provides detailed account information for
- listed accounts"""
-
- cmd = listAccounts.listAccountsCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listAccounts(cmd))
-
-
-def list_users(apiclient, **kwargs):
- """Lists users and provides detailed account information for
- listed users"""
-
- cmd = listUsers.listUsersCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listUsers(cmd))
-
-
-def list_snapshot_policy(apiclient, **kwargs):
- """Lists snapshot policies."""
-
- cmd = listSnapshotPolicies.listSnapshotPoliciesCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listSnapshotPolicies(cmd))
-
-
-def list_events(apiclient, **kwargs):
- """Lists events"""
-
- cmd = listEvents.listEventsCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listEvents(cmd))
-
-
-def list_disk_offering(apiclient, **kwargs):
- """Lists all available disk offerings."""
-
- cmd = listDiskOfferings.listDiskOfferingsCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listDiskOfferings(cmd))
-
-
-def list_service_offering(apiclient, **kwargs):
- """Lists all available service offerings."""
-
- cmd = listServiceOfferings.listServiceOfferingsCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listServiceOfferings(cmd))
-
-
-def list_vlan_ipranges(apiclient, **kwargs):
- """Lists all VLAN IP ranges."""
-
- cmd = listVlanIpRanges.listVlanIpRangesCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listVlanIpRanges(cmd))
-
-
-def list_usage_records(apiclient, **kwargs):
- """Lists usage records for accounts"""
-
- cmd = listUsageRecords.listUsageRecordsCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listUsageRecords(cmd))
-
-
-def list_nw_service_prividers(apiclient, **kwargs):
- """Lists Network service providers"""
-
- cmd = listNetworkServiceProviders.listNetworkServiceProvidersCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listNetworkServiceProviders(cmd))
-
-
-def list_virtual_router_elements(apiclient, **kwargs):
- """Lists Virtual Router elements"""
-
- cmd = listVirtualRouterElements.listVirtualRouterElementsCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listVirtualRouterElements(cmd))
-
-
-def list_network_offerings(apiclient, **kwargs):
- """Lists network offerings"""
-
- cmd = listNetworkOfferings.listNetworkOfferingsCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listNetworkOfferings(cmd))
-
-
-def list_resource_limits(apiclient, **kwargs):
- """Lists resource limits"""
-
- cmd = listResourceLimits.listResourceLimitsCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listResourceLimits(cmd))
-
-def list_vpc_offerings(apiclient, **kwargs):
- """ Lists VPC offerings """
-
- cmd = listVPCOfferings.listVPCOfferingsCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listVPCOfferings(cmd))
-
-def update_resource_count(apiclient, domainid, accountid=None,
- projectid=None, rtype=None):
- """updates the resource count
- 0 - VM
- 1 - Public IP
- 2 - Volume
- 3 - Snapshot
- 4 - Template
- 5 - Projects
- 6 - Network
- 7 - VPC
- 8 - CPUs
- 9 - RAM
- 10 - Primary (shared) storage (Volumes)
- 11 - Secondary storage (Snapshots, Templates & ISOs)
- """
-
- Resources.updateCount(apiclient,
- domainid=domainid,
- account=accountid if accountid else None,
- projectid=projectid if projectid else None,
- resourcetype=rtype if rtype else None
- )
- return
-
-def find_suitable_host(apiclient, vm):
- """Returns a suitable host for VM migration"""
-
- hosts = Host.list(apiclient,
- virtualmachineid=vm.id,
- listall=True)
-
- if isinstance(hosts, list):
- assert len(hosts) > 0, "List host should return valid response"
- else:
- raise Exception("Exception: List host should return valid response")
- return hosts[0]
-
-def get_resource_type(resource_id):
- """Returns resource type"""
-
- lookup = { 0: "VM",
- 1: "Public IP",
- 2: "Volume",
- 3: "Snapshot",
- 4: "Template",
- 5: "Projects",
- 6: "Network",
- 7: "VPC",
- 8: "CPUs",
- 9: "RAM",
- 10: "Primary (shared) storage (Volumes)",
- 11: "Secondary storage (Snapshots, Templates & ISOs)"
- }
-
- return lookup[resource_id]
-
-def get_portable_ip_range_services(config):
- """ Reads config values related to portable ip and fills up
- services accordingly"""
-
- services = {}
- attributeError = False
-
- if config.portableIpRange.startip:
- services["startip"] = config.portableIpRange.startip
- else:
- attributeError = True
-
- if config.portableIpRange.endip:
- services["endip"] = config.portableIpRange.endip
- else:
- attributeError = True
-
- if config.portableIpRange.netmask:
- services["netmask"] = config.portableIpRange.netmask
- else:
- attributeError = True
-
- if config.portableIpRange.gateway:
- services["gateway"] = config.portableIpRange.gateway
- else:
- attributeError = True
-
- if config.portableIpRange.vlan:
- services["vlan"] = config.portableIpRange.vlan
-
- if attributeError:
- services = None
-
- return services
-
-def get_free_vlan(apiclient, zoneid):
- """
- Find an unallocated VLAN outside the range allocated to the physical network.
-
- @note: This does not guarantee that the VLAN is available for use in
- the deployment's network gear
- @return: physical_network, shared_vlan_tag
- """
- list_physical_networks_response = PhysicalNetwork.list(
- apiclient,
- zoneid=zoneid
- )
- assert isinstance(list_physical_networks_response, list)
- assert len(list_physical_networks_response) > 0, "No physical networks found in zone %s" % zoneid
-
- physical_network = list_physical_networks_response[0]
-
- networks = list_networks(apiclient, zoneid= zoneid, type='Shared')
- usedVlanIds = []
-
- if isinstance(networks, list) and len(networks) > 0:
- usedVlanIds = [int(nw.vlan) for nw in networks if nw.vlan!="untagged"]
-
- if hasattr(physical_network, "vlan") is False:
- while True:
- shared_ntwk_vlan = random.randrange(1,4095)
- if shared_ntwk_vlan in usedVlanIds:
- continue
- else:
- break
- else:
- vlans = xsplit(physical_network.vlan, ['-', ','])
-
- assert len(vlans) > 0
- assert int(vlans[0]) < int(vlans[-1]), "VLAN range %s was improperly split" % physical_network.vlan
-
- retriesCount = 20 #Assuming random function will give different integer each time
-
- shared_ntwk_vlan = None
-
- while True:
-
- if retriesCount == 0:
- break
-
- free_vlan = int(vlans[-1]) + random.randrange(1, 20)
-
- if free_vlan > 4095:
- free_vlan = int(vlans[0]) - random.randrange(1, 20)
- if free_vlan < 0 or (free_vlan in usedVlanIds):
- retriesCount -= 1
- continue
- else:
- shared_ntwk_vlan = free_vlan
- break
-
- return physical_network, shared_ntwk_vlan
-
-def setNonContiguousVlanIds(apiclient, zoneid):
- """
- Form the non contiguous ranges based on currently assigned range in physical network
- """
-
- NonContigVlanIdsAcquired = False
-
- list_physical_networks_response = PhysicalNetwork.list(
- apiclient,
- zoneid=zoneid
- )
- assert isinstance(list_physical_networks_response, list)
- assert len(list_physical_networks_response) > 0, "No physical networks found in zone %s" % zoneid
-
- for physical_network in list_physical_networks_response:
-
- vlans = xsplit(physical_network.vlan, ['-', ','])
-
- assert len(vlans) > 0
- assert int(vlans[0]) < int(vlans[-1]), "VLAN range %s was improperly split" % physical_network.vlan
-
- # Keep some gap between existing vlan and the new vlans which we are going to add
- # So that they are non contiguous
-
- non_contig_end_vlan_id = int(vlans[-1]) + 6
- non_contig_start_vlan_id = int(vlans[0]) - 6
-
- # Form ranges which are consecutive to existing ranges but not immediately contiguous
- # There should be gap in between existing range and new non contiguous ranage
-
- # If you can't add range after existing range, because it's crossing 4095, then
- # select VLAN ids before the existing range such that they are greater than 0, and
- # then add this non contiguoud range
- vlan = { "partial_range": ["",""], "full_range": ""}
-
- if non_contig_end_vlan_id < 4095:
- vlan["partial_range"][0] = str(non_contig_end_vlan_id - 4) + '-' + str(non_contig_end_vlan_id - 3)
- vlan["partial_range"][1] = str(non_contig_end_vlan_id - 1) + '-' + str(non_contig_end_vlan_id)
- vlan["full_range"] = str(non_contig_end_vlan_id - 4) + '-' + str(non_contig_end_vlan_id)
- NonContigVlanIdsAcquired = True
-
- elif non_contig_start_vlan_id > 0:
- vlan["partial_range"][0] = str(non_contig_start_vlan_id) + '-' + str(non_contig_start_vlan_id + 1)
- vlan["partial_range"][1] = str(non_contig_start_vlan_id + 3) + '-' + str(non_contig_start_vlan_id + 4)
- vlan["full_range"] = str(non_contig_start_vlan_id) + '-' + str(non_contig_start_vlan_id + 4)
- NonContigVlanIdsAcquired = True
-
- else:
- NonContigVlanIdsAcquired = False
-
- # If failed to get relevant vlan ids, continue to next physical network
- # else break from loop as we have hot the non contiguous vlan ids for the test purpose
-
- if not NonContigVlanIdsAcquired:
- continue
- else:
- break
-
- # If even through looping from all existing physical networks, failed to get relevant non
- # contiguous vlan ids, then fail the test case
-
- if not NonContigVlanIdsAcquired:
- return None, None
-
- return physical_network, vlan
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/tools/marvin/marvin/integration/lib/utils.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/integration/lib/utils.py b/tools/marvin/marvin/integration/lib/utils.py
deleted file mode 100644
index 957807d..0000000
--- a/tools/marvin/marvin/integration/lib/utils.py
+++ /dev/null
@@ -1,472 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-"""Utilities functions
-"""
-
-import marvin
-import os
-import time
-import logging
-import string
-import random
-import imaplib
-import email
-import socket
-import urlparse
-import datetime
-from platform import system
-from marvin.cloudstackAPI import cloudstackAPIClient, listHosts
-from cloudstackException import GetDetailExceptionInfo
-from marvin.sshClient import SshClient
-from marvin.codes import (
- SUCCESS,
- FAIL,
- PASS,
- MATCH_NOT_FOUND,
- INVALID_INPUT,
- EMPTY_LIST,
- FAILED)
-
-def restart_mgmt_server(server):
- """Restarts the management server"""
-
- try:
- # Get the SSH client
- ssh = is_server_ssh_ready(
- server["ipaddress"],
- server["port"],
- server["username"],
- server["password"],
- )
- result = ssh.execute("/etc/init.d/cloud-management restart")
- res = str(result)
- # Server Stop - OK
- # Server Start - OK
- if res.count("OK") != 2:
- raise ("ErrorInReboot!")
- except Exception as e:
- raise e
- return
-
-
-def fetch_latest_mail(services, from_mail):
- """Fetch mail"""
-
- # Login to mail server to verify email
- mail = imaplib.IMAP4_SSL(services["server"])
- mail.login(
- services["email"],
- services["password"]
- )
- mail.list()
- mail.select(services["folder"])
- date = (datetime.date.today() - datetime.timedelta(1)).strftime("%d-%b-%Y")
-
- result, data = mail.uid(
- 'search',
- None,
- '(SENTSINCE {date} HEADER FROM "{mail}")'.format(
- date=date,
- mail=from_mail
- )
- )
- # Return False if email is not present
- if data == []:
- return False
-
- latest_email_uid = data[0].split()[-1]
- result, data = mail.uid('fetch', latest_email_uid, '(RFC822)')
- raw_email = data[0][1]
- email_message = email.message_from_string(raw_email)
- result = get_first_text_block(email_message)
- return result
-
-
-def get_first_text_block(email_message_instance):
- """fetches first text block from the mail"""
- maintype = email_message_instance.get_content_maintype()
- if maintype == 'multipart':
- for part in email_message_instance.get_payload():
- if part.get_content_maintype() == 'text':
- return part.get_payload()
- elif maintype == 'text':
- return email_message_instance.get_payload()
-
-
-def random_gen(id=None, size=6, chars=string.ascii_uppercase + string.digits):
- """Generate Random Strings of variable length"""
- randomstr = ''.join(random.choice(chars) for x in range(size))
- if id:
- return ''.join([id, '-', randomstr])
- return randomstr
-
-
-def cleanup_resources(api_client, resources):
- """Delete resources"""
- for obj in resources:
- obj.delete(api_client)
-
-
-def is_server_ssh_ready(ipaddress, port, username, password, retries=20, retryinterv=30, timeout=10.0, keyPairFileLocation=None):
- '''
- @Name: is_server_ssh_ready
- @Input: timeout: tcp connection timeout flag,
- others information need to be added
- @Output:object for SshClient
- Name of the function is little misnomer and is not
- verifying anything as such mentioned
- '''
-
- try:
- ssh = SshClient(
- host=ipaddress,
- port=port,
- user=username,
- passwd=password,
- keyPairFiles=keyPairFileLocation,
- retries=retries,
- delay=retryinterv,
- timeout=timeout)
- except Exception, e:
- raise Exception("SSH connection has Failed. Waited %ss. Error is %s" % (retries * retryinterv, str(e)))
- else:
- return ssh
-
-
-def format_volume_to_ext3(ssh_client, device="/dev/sda"):
- """Format attached storage to ext3 fs"""
- cmds = [
- "echo -e 'n\np\n1\n\n\nw' | fdisk %s" % device,
- "mkfs.ext3 %s1" % device,
- ]
- for c in cmds:
- ssh_client.execute(c)
-
-
-def fetch_api_client(config_file='datacenterCfg'):
- """Fetch the Cloudstack API Client"""
- config = marvin.configGenerator.get_setup_config(config_file)
- mgt = config.mgtSvr[0]
- testClientLogger = logging.getLogger("testClient")
- asyncTimeout = 3600
- return cloudstackAPIClient.CloudStackAPIClient(
- marvin.cloudstackConnection.cloudConnection(
- mgt,
- asyncTimeout,
- testClientLogger
- )
- )
-
-def get_host_credentials(config, hostip):
- """Get login information for a host `hostip` (ipv4) from marvin's `config`
-
- @return the tuple username, password for the host else raise keyerror"""
- for zone in config.zones:
- for pod in zone.pods:
- for cluster in pod.clusters:
- for host in cluster.hosts:
- if str(host.url).startswith('http'):
- hostname = urlparse.urlsplit(str(host.url)).netloc
- else:
- hostname = str(host.url)
- try:
- if socket.getfqdn(hostip) == socket.getfqdn(hostname):
- return host.username, host.password
- except socket.error, e:
- raise Exception("Unresolvable host %s error is %s" % (hostip, e))
- raise KeyError("Please provide the marvin configuration file with credentials to your hosts")
-
-
-def get_process_status(hostip, port, username, password, linklocalip, process, hypervisor=None):
- """Double hop and returns a process status"""
-
- #SSH to the machine
- ssh = SshClient(hostip, port, username, password)
- if str(hypervisor).lower() == 'vmware':
- ssh_command = "ssh -i /var/cloudstack/management/.ssh/id_rsa -ostricthostkeychecking=no "
- else:
- ssh_command = "ssh -i ~/.ssh/id_rsa.cloud -ostricthostkeychecking=no "
-
- ssh_command = ssh_command +\
- "-oUserKnownHostsFile=/dev/null -p 3922 %s %s" % (
- linklocalip,
- process)
-
- # Double hop into router
- timeout = 5
- # Ensure the SSH login is successful
- while True:
- res = ssh.execute(ssh_command)
-
- if res[0] != "Host key verification failed.":
- break
- elif timeout == 0:
- break
-
- time.sleep(5)
- timeout = timeout - 1
- return res
-
-
-def isAlmostEqual(first_digit, second_digit, range=0):
- digits_equal_within_range = False
-
- try:
- if ((first_digit - range) < second_digit < (first_digit + range)):
- digits_equal_within_range = True
- except Exception as e:
- raise e
- return digits_equal_within_range
-
-
-def xsplit(txt, seps):
- """
- Split a string in `txt` by list of delimiters in `seps`
- @param txt: string to split
- @param seps: list of separators
- @return: list of split units
- """
- default_sep = seps[0]
- for sep in seps[1:]: # we skip seps[0] because that's the default separator
- txt = txt.replace(sep, default_sep)
- return [i.strip() for i in txt.split(default_sep)]
-
-def get_hypervisor_type(apiclient):
-
- """Return the hypervisor type of the hosts in setup"""
-
- cmd = listHosts.listHostsCmd()
- cmd.type = 'Routing'
- cmd.listall = True
- hosts = apiclient.listHosts(cmd)
- hosts_list_validation_result = validateList(hosts)
- assert hosts_list_validation_result[0] == PASS, "host list validation failed"
- return hosts_list_validation_result[1].hypervisor
-
-def is_snapshot_on_nfs(apiclient, dbconn, config, zoneid, snapshotid):
- """
- Checks whether a snapshot with id (not UUID) `snapshotid` is present on the nfs storage
-
- @param apiclient: api client connection
- @param @dbconn: connection to the cloudstack db
- @param config: marvin configuration file
- @param zoneid: uuid of the zone on which the secondary nfs storage pool is mounted
- @param snapshotid: uuid of the snapshot
- @return: True if snapshot is found, False otherwise
- """
- # snapshot extension to be appended to the snapshot path obtained from db
- snapshot_extensions = {"vmware": ".ovf",
- "kvm": "",
- "xenserver": ".vhd"}
-
- qresultset = dbconn.execute(
- "select id from snapshots where uuid = '%s';" \
- % str(snapshotid)
- )
- if len(qresultset) == 0:
- raise Exception(
- "No snapshot found in cloudstack with id %s" % snapshotid)
-
-
- snapshotid = qresultset[0][0]
- qresultset = dbconn.execute(
- "select install_path,store_id from snapshot_store_ref where snapshot_id='%s' and store_role='Image';" % snapshotid
- )
-
- assert isinstance(qresultset, list), "Invalid db query response for snapshot %s" % snapshotid
-
- if len(qresultset) == 0:
- #Snapshot does not exist
- return False
-
- from base import ImageStore
- #pass store_id to get the exact storage pool where snapshot is stored
- secondaryStores = ImageStore.list(apiclient, zoneid=zoneid, id=int(qresultset[0][1]))
-
- assert isinstance(secondaryStores, list), "Not a valid response for listImageStores"
- assert len(secondaryStores) != 0, "No image stores found in zone %s" % zoneid
-
- secondaryStore = secondaryStores[0]
-
- if str(secondaryStore.providername).lower() != "nfs":
- raise Exception(
- "is_snapshot_on_nfs works only against nfs secondary storage. found %s" % str(secondaryStore.providername))
-
- hypervisor = get_hypervisor_type(apiclient)
- # append snapshot extension based on hypervisor, to the snapshot path
- snapshotPath = str(qresultset[0][0]) + snapshot_extensions[str(hypervisor).lower()]
-
- nfsurl = secondaryStore.url
- from urllib2 import urlparse
- parse_url = urlparse.urlsplit(nfsurl, scheme='nfs')
- host, path = parse_url.netloc, parse_url.path
-
- if not config.mgtSvr:
- raise Exception("Your marvin configuration does not contain mgmt server credentials")
- mgtSvr, user, passwd = config.mgtSvr[0].mgtSvrIp, config.mgtSvr[0].user, config.mgtSvr[0].passwd
-
- try:
- ssh_client = SshClient(
- mgtSvr,
- 22,
- user,
- passwd
- )
- cmds = [
- "mkdir -p %s /mnt/tmp",
- "mount -t %s %s%s /mnt/tmp" % (
- 'nfs',
- host,
- path,
- ),
- "test -f %s && echo 'snapshot exists'" % (
- os.path.join("/mnt/tmp", snapshotPath)
- ),
- ]
-
- for c in cmds:
- result = ssh_client.execute(c)
-
- # Unmount the Sec Storage
- cmds = [
- "cd",
- "umount /mnt/tmp",
- ]
- for c in cmds:
- ssh_client.execute(c)
- except Exception as e:
- raise Exception("SSH failed for management server: %s - %s" %
- (config.mgtSvr[0].mgtSvrIp, e))
- return 'snapshot exists' in result
-
-def validateList(inp):
- """
- @name: validateList
- @Description: 1. A utility function to validate
- whether the input passed is a list
- 2. The list is empty or not
- 3. If it is list and not empty, return PASS and first element
- 4. If not reason for FAIL
- @Input: Input to be validated
- @output: List, containing [ Result,FirstElement,Reason ]
- Ist Argument('Result') : FAIL : If it is not a list
- If it is list but empty
- PASS : If it is list and not empty
- IInd Argument('FirstElement'): If it is list and not empty,
- then first element
- in it, default to None
- IIIrd Argument( 'Reason' ): Reason for failure ( FAIL ),
- default to None.
- INVALID_INPUT
- EMPTY_LIST
- """
- ret = [FAIL, None, None]
- if inp is None:
- ret[2] = INVALID_INPUT
- return ret
- if not isinstance(inp, list):
- ret[2] = INVALID_INPUT
- return ret
- if len(inp) == 0:
- ret[2] = EMPTY_LIST
- return ret
- return [PASS, inp[0], None]
-
-def verifyElementInList(inp, toverify, responsevar=None, pos=0):
- '''
- @name: verifyElementInList
- @Description:
- 1. A utility function to validate
- whether the input passed is a list.
- The list is empty or not.
- If it is list and not empty, verify
- whether a given element is there in that list or not
- at a given pos
- @Input:
- I : Input to be verified whether its a list or not
- II : Element to verify whether it exists in the list
- III : variable name in response object to verify
- default to None, if None, we will verify for the complete
- first element EX: state of response object object
- IV : Position in the list at which the input element to verify
- default to 0
- @output: List, containing [ Result,Reason ]
- Ist Argument('Result') : FAIL : If it is not a list
- If it is list but empty
- PASS : If it is list and not empty
- and matching element was found
- IIrd Argument( 'Reason' ): Reason for failure ( FAIL ),
- default to None.
- INVALID_INPUT
- EMPTY_LIST
- MATCH_NOT_FOUND
- '''
- if toverify is None or toverify == '' \
- or pos is None or pos < -1 or pos == '':
- return [FAIL, INVALID_INPUT]
- out = validateList(inp)
- if out[0] == FAIL:
- return [FAIL, out[2]]
- if len(inp) > pos:
- if responsevar is None:
- if inp[pos] == toverify:
- return [PASS, None]
- else:
- if responsevar in inp[pos].__dict__ and getattr(inp[pos], responsevar) == toverify:
- return [PASS, None]
- else:
- return [FAIL, MATCH_NOT_FOUND]
- else:
- return [FAIL, MATCH_NOT_FOUND]
-
-
-def checkVolumeSize(ssh_handle=None,
- volume_name="/dev/sda",
- cmd_inp="/sbin/fdisk -l | grep Disk",
- size_to_verify=0):
- '''
- @Name : getDiskUsage
- @Desc : provides facility to verify the volume size against the size to verify
- @Input: 1. ssh_handle : machine against which to execute the disk size cmd
- 2. volume_name : The name of the volume against which to verify the size
- 3. cmd_inp : Input command used to veify the size
- 4. size_to_verify: size against which to compare.
- @Output: Returns FAILED in case of an issue, else SUCCESS
- '''
- try:
- if ssh_handle is None or cmd_inp is None or volume_name is None:
- return INVALID_INPUT
-
- cmd = cmd_inp
- '''
- Retrieve the cmd output
- '''
- if system().lower() != "windows":
- fdisk_output = ssh_handle.runCommand(cmd_inp)
- if fdisk_output["status"] != SUCCESS:
- return FAILED
- temp_out = fdisk_output["stdout"]
- for line in temp_out.split("\n"):
- if volume_name in line:
- parts = line.split()
- if str(parts[-2]) == str(size_to_verify):
- return [SUCCESS,str(parts[-2])]
- return [FAILED,"Volume Not Found"]
- except Exception, e:
- print "\n Exception Occurred under getDiskUsage: " \
- "%s" %GetDetailExceptionInfo(e)
- return [FAILED,GetDetailExceptionInfo(e)]
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf72441d/tools/marvin/marvin/lib/__init__.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/lib/__init__.py b/tools/marvin/marvin/lib/__init__.py
index e69de29..978b68a 100644
--- a/tools/marvin/marvin/lib/__init__.py
+++ b/tools/marvin/marvin/lib/__init__.py
@@ -0,0 +1,16 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.