cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kis...@apache.org
Subject [34/50] [abbrv] git commit: updated refs/heads/baremetal-systemvm to 23482b1
Date Tue, 21 Oct 2014 14:57:12 GMT
Merge remote-tracking branch 'origin/4.5' into merge-master

Conflicts:
	engine/schema/src/com/cloud/upgrade/dao/Upgrade441to450.java
	plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BaremetalManagerImpl.java
	plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BaremetalVlanManager.java
	plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BaremetalVlanManagerImpl.java
	plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalKickStartServiceImpl.java
	plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageProcessor.java
	server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
	server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java
	setup/db/db/schema-441to450.sql
	test/integration/component/test_deploy_vgpu_vm.py
	tools/marvin/marvin/config/test_data.py


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/148efbb7
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/148efbb7
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/148efbb7

Branch: refs/heads/baremetal-systemvm
Commit: 148efbb73f0e084614eff62f48ea9fa964c64da8
Parents: 1f8cf0b 420d4e0
Author: Daan Hoogland <daan@onecht.net>
Authored: Thu Oct 16 12:29:37 2014 +0200
Committer: Daan Hoogland <daan@onecht.net>
Committed: Thu Oct 16 12:29:37 2014 +0200

----------------------------------------------------------------------
 api/src/com/cloud/event/EventTypes.java         |   1 -
 .../PrepareKickstartPxeServerCommand.java       |  84 ++++++
 .../core/spring-baremetal-core-context.xml      |   8 +-
 .../baremetal/manager/BaremetalManager.java     |   3 -
 .../baremetal/manager/BaremetalManagerImpl.java |   3 -
 .../baremetal/manager/BaremetalVlanManager.java |   1 -
 .../manager/BaremetalVlanManagerImpl.java       |   7 +-
 .../networkservice/BareMetalResourceBase.java   |  47 +--
 .../BaremetalKickStartPxeResource.java          |   1 +
 .../BaremetalKickStartServiceImpl.java          |  12 +-
 .../networkservice/BaremetalPxeElement.java     |   5 +-
 .../Force10BaremetalSwitchBackend.java          | 116 ++------
 .../PrepareKickstartPxeServerCommand.java       |  83 ------
 .../BaremetalProvisionDoneNotificationCmd.java  |  87 ------
 server/src/com/cloud/configuration/Config.java  |  36 +--
 .../deploy/DeploymentPlanningManagerImpl.java   |  11 +-
 .../VirtualNetworkApplianceManagerImpl.java     |   2 -
 .../com/cloud/resource/ResourceManagerImpl.java |  15 +
 .../com/cloud/storage/VolumeApiServiceImpl.java |  12 +-
 .../cloud/storage/VolumeApiServiceImplTest.java |  24 +-
 .../patches/debian/config/etc/dnsmasq.conf.tmpl |   6 +-
 .../config/opt/cloud/bin/baremetal_snat.sh      |  21 +-
 .../debian/config/opt/cloud/bin/prepare_pxe.sh  |  28 +-
 .../component/test_deploy_vgpu_vm.py            | 291 ++++++++++++++++++-
 .../com/cloud/utils/xmlobject/XmlObject.java    |  15 +-
 .../cloud/utils/xmlobject/XmlObjectParser.java  |  22 +-
 .../cloud/utils/xmlobject/TestXmlObject.java    |   5 -
 27 files changed, 486 insertions(+), 460 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/148efbb7/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BaremetalManagerImpl.java
----------------------------------------------------------------------
diff --cc plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BaremetalManagerImpl.java
index f826ae9,f6a4113..076a1bc
--- a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BaremetalManagerImpl.java
+++ b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BaremetalManagerImpl.java
@@@ -118,41 -107,6 +116,40 @@@ public class BaremetalManagerImpl exten
      public List<Class<?>> getCommands() {
          List<Class<?>> cmds = new ArrayList<Class<?>>();
          cmds.add(AddBaremetalHostCmd.class);
-         cmds.add(BaremetalProvisionDoneNotificationCmd.class);
          return cmds;
      }
 +
 +    @Override
 +    public void notifyProvisionDone(BaremetalProvisionDoneNotificationCmd cmd) {
 +        QueryBuilder<HostVO> hq = QueryBuilder.create(HostVO.class);
 +        hq.and(hq.entity().getPrivateMacAddress(), SearchCriteria.Op.EQ, cmd.getMac());
 +        HostVO host = hq.find();
 +        if (host == null) {
 +            throw new CloudRuntimeException(String.format("cannot find host[mac:%s]", cmd.getMac()));
 +        }
 +
 +        _hostDao.loadDetails(host);
 +        String vmName = host.getDetail("vmName");
 +        if (vmName == null) {
 +            throw new CloudRuntimeException(String.format("cannot find any baremetal instance
running on host[mac:%s]", cmd.getMac()));
 +        }
 +
 +        QueryBuilder<VMInstanceVO> vmq = QueryBuilder.create(VMInstanceVO.class);
 +        vmq.and(vmq.entity().getInstanceName(), SearchCriteria.Op.EQ, vmName);
 +        VMInstanceVO vm = vmq.find();
 +
 +        if (vm == null) {
 +            throw new CloudRuntimeException(String.format("cannot find baremetal instance[name:%s]",
vmName));
 +        }
 +
 +        if (State.Starting != vm.getState()) {
 +            throw new CloudRuntimeException(String.format("baremetal instance[name:%s, state:%s]
is not in state of Starting", vmName, vm.getState()));
 +        }
 +
 +        vm.setState(State.Running);
 +        vm.setLastHostId(vm.getHostId());
 +        vmDao.update(vm.getId(), vm);
 +        s_logger.debug(String.format("received baremetal provision done notification for
vm[id:%s name:%s] running on host[mac:%s, ip:%s]",
 +                vm.getId(), vm.getInstanceName(), host.getPrivateMacAddress(), host.getPrivateIpAddress()));
 +    }
  }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/148efbb7/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BaremetalVlanManager.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/148efbb7/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BaremetalVlanManagerImpl.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/148efbb7/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BareMetalResourceBase.java
----------------------------------------------------------------------
diff --cc plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BareMetalResourceBase.java
index ab863dc,fedfb8b..8ed50ef
--- a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BareMetalResourceBase.java
+++ b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BareMetalResourceBase.java
@@@ -58,9 -59,8 +58,7 @@@ import com.cloud.configuration.Config
  import com.cloud.host.Host.Type;
  import com.cloud.hypervisor.Hypervisor;
  import com.cloud.resource.ServerResource;
 -import com.cloud.utils.Pair;
  import com.cloud.utils.component.ManagerBase;
- import com.cloud.utils.db.QueryBuilder;
- import com.cloud.utils.db.SearchCriteria;
  import com.cloud.utils.exception.CloudRuntimeException;
  import com.cloud.utils.script.OutputInterpreter;
  import com.cloud.utils.script.Script;
@@@ -404,12 -391,11 +392,12 @@@ public class BareMetalResourceBase exte
                  VMInstanceVO vm = vms.get(0);
                  SecurityGroupHttpClient client = new SecurityGroupHttpClient();
                  HashMap<String, Pair<Long, Long>> nwGrpStates = client.sync(vm.getInstanceName(),
vm.getId(), vm.getPrivateIpAddress());
-                 return new PingRoutingWithNwGroupsCommand(getType(), id, null, nwGrpStates);
+                 return new PingRoutingWithNwGroupsCommand(getType(), id, getHostVmStateReport(),
nwGrpStates);
              }
          } else {
 -            return new PingRoutingCommand(getType(), id, getHostVmStateReport());
 +            return new PingRoutingCommand(getType(), id, null);
          }
 +            */
      }
  
      protected Answer execute(IpmISetBootDevCommand cmd) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/148efbb7/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalKickStartServiceImpl.java
----------------------------------------------------------------------
diff --cc plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalKickStartServiceImpl.java
index 7f6b0bf,2786e13..f668155
--- a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalKickStartServiceImpl.java
+++ b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalKickStartServiceImpl.java
@@@ -224,24 -218,20 +223,19 @@@ public class BaremetalKickStartServiceI
              throw new CloudRuntimeException(String.format("cannot find management nic on
virtual router[id:%s]", vr.getId()));
          }
  
-         String internalServerIp = _configDao.getValue(Config.BaremetalInternalStorageServer.key());
-         if (internalServerIp == null) {
-             throw new CloudRuntimeException(String.format("please specify 'baremetal.internal.storage.server.ip',
which is the http server/nfs server storing kickstart files and ISO files, in global setting"));
-         }
- 
          List<String> tuple =  parseKickstartUrl(profile);
 -        Pair<Boolean, String> ret = SshHelper.sshExecute(mgmtNic.getIp4Address(),
3922, "root", getSystemVMKeyFile(), null,
 -                String.format("/usr/bin/prepare_pxe.sh %s %s %s %s %s", tuple.get(1), tuple.get(2),
profile.getTemplate().getUuid(),
 -                        String.format("01-%s", nic.getMacAddress().replaceAll(":", "-")),
tuple.get(0))
 -                );
 +        String cmd =  String.format("/opt/cloud/bin/prepare_pxe.sh %s %s %s %s %s %s", tuple.get(1),
tuple.get(2), profile.getTemplate().getUuid(),
 +                String.format("01-%s", nic.getMacAddress().replaceAll(":", "-")).toLowerCase(),
tuple.get(0), nic.getMacAddress().toLowerCase());
 +        s_logger.debug(String.format("prepare pxe on virtual router[ip:%s], cmd: %s", mgmtNic.getIp4Address(),
cmd));
 +        Pair<Boolean, String> ret = SshHelper.sshExecute(mgmtNic.getIp4Address(),
3922, "root", getSystemVMKeyFile(), null, cmd);
          if (!ret.first()) {
              throw new CloudRuntimeException(String.format("failed preparing PXE in virtual
router[id:%s], because %s", vr.getId(), ret.second()));
          }
  
-         //String internalServerIp = "10.223.110.231";
 -        //String internalServerIp = _configDao.getValue(Config.BaremetalInternalStorageServer.key());
+         String internalServerIp = "10.223.110.231";
 -        ret = SshHelper.sshExecute(mgmtNic.getIp4Address(), 3922, "root", getSystemVMKeyFile(),
null,
 -                String.format("/usr/bin/baremetal_snat.sh %s %s", mgmtNic.getIp4Address(),
internalServerIp)
 -                );
 +        cmd = String.format("/opt/cloud/bin/baremetal_snat.sh %s %s %s", mgmtNic.getIp4Address(),
internalServerIp, mgmtNic.getGateway());
 +        s_logger.debug(String.format("prepare SNAT on virtual router[ip:%s], cmd: %s", mgmtNic.getIp4Address(),
cmd));
 +        ret = SshHelper.sshExecute(mgmtNic.getIp4Address(), 3922, "root", getSystemVMKeyFile(),
null, cmd);
          if (!ret.first()) {
              throw new CloudRuntimeException(String.format("failed preparing PXE in virtual
router[id:%s], because %s", vr.getId(), ret.second()));
          }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/148efbb7/server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/148efbb7/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
----------------------------------------------------------------------
diff --cc server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
index 315bdde,cc9ced4..be7cb37
mode 100644,100755..100644
--- a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
+++ b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/148efbb7/server/src/com/cloud/resource/ResourceManagerImpl.java
----------------------------------------------------------------------
diff --cc server/src/com/cloud/resource/ResourceManagerImpl.java
index c7ba80a,a0a3adf..cdad91e
--- a/server/src/com/cloud/resource/ResourceManagerImpl.java
+++ b/server/src/com/cloud/resource/ResourceManagerImpl.java
@@@ -1631,23 -1631,22 +1631,38 @@@ public class ResourceManagerImpl extend
                  clusterId = c.getId();
              }
          }
+         if (startup instanceof StartupRoutingCommand) {
+             StartupRoutingCommand ssCmd = ((StartupRoutingCommand)startup);
+             List<String> implicitHostTags = ssCmd.getHostTags();
+             if (!implicitHostTags.isEmpty()) {
+                 if (hostTags == null) {
+                     hostTags = _hostTagsDao.gethostTags(host.getId());
+                 }
+                 if (hostTags != null) {
+                     implicitHostTags.removeAll(hostTags);
+                     hostTags.addAll(implicitHostTags);
+                 } else {
+                     hostTags = implicitHostTags;
+                 }
+             }
+         }
  
 +        if (startup instanceof StartupRoutingCommand) {
 +            StartupRoutingCommand ssCmd = ((StartupRoutingCommand)startup);
 +            List<String> implicitHostTags = ssCmd.getHostTags();
 +            if (!implicitHostTags.isEmpty()) {
 +                if (hostTags == null) {
 +                    hostTags = _hostTagsDao.gethostTags(host.getId());
 +                }
 +                if (hostTags != null) {
 +                    implicitHostTags.removeAll(hostTags);
 +                    hostTags.addAll(implicitHostTags);
 +                } else {
 +                    hostTags = implicitHostTags;
 +                }
 +            }
 +        }
 +
          host.setDataCenterId(dc.getId());
          host.setPodId(podId);
          host.setClusterId(clusterId);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/148efbb7/systemvm/patches/debian/config/opt/cloud/bin/baremetal_snat.sh
----------------------------------------------------------------------
diff --cc systemvm/patches/debian/config/opt/cloud/bin/baremetal_snat.sh
index 22e5669,0000000..f35a16f
mode 100755,000000..100755
--- a/systemvm/patches/debian/config/opt/cloud/bin/baremetal_snat.sh
+++ b/systemvm/patches/debian/config/opt/cloud/bin/baremetal_snat.sh
@@@ -1,54 -1,0 +1,35 @@@
 +#!/bin/bash
 +
 +#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.
 +
 +set +u
 +
 +mgmt_nic_ip=$1
 +internal_server_ip=$2
- gateway_ip=$3
 +
 +ip route | grep "$internal_server_ip" > /dev/null
 +
 +if [ $? -ne 0 ]; then
-     ip route add $internal_server_ip via $gateway_ip
++    ip route add $internal_server_ip via $mgmt_nic_ip
 +fi
 +
 +iptables-save | grep -- "-A POSTROUTING -d $internal_server_ip" > /dev/null
 +
 +if [ $? -ne 0 ]; then
 +    iptables -t nat -A POSTROUTING -d $internal_server_ip -j SNAT --to-source $mgmt_nic_ip
 +fi
- 
- 
- iptables-save | grep -- "-A INPUT -i eth0 -p udp -m udp --dport 69 -j ACCEPT" > /dev/null
- if [ $? -ne 0 ]; then
-     iptables -I INPUT -i eth0 -p udp -m udp --dport 69 -j ACCEPT
- fi
- 
- iptables-save | grep -- "-A FORWARD -i eth1 -o eth0 -j ACCEPT" > /dev/null
- if [ $? -ne 0 ]; then
-     iptables -A FORWARD -i eth1 -o eth0 -j ACCEPT
- fi
- 
- rule="-A FORWARD -d $internal_server_ip/32 -i eth0 -o eth1 -j ACCEPT"
- iptables-save | grep -- "$rule" > /dev/null
- if [ $? -ne 0 ]; then 
-     iptables -I FORWARD -d $internal_server_ip/32 -i eth0 -o eth1 -j ACCEPT
- fi
- 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/148efbb7/systemvm/patches/debian/config/opt/cloud/bin/prepare_pxe.sh
----------------------------------------------------------------------
diff --cc systemvm/patches/debian/config/opt/cloud/bin/prepare_pxe.sh
index 5bc1a93,0000000..bd9ece6
mode 100755,000000..100755
--- a/systemvm/patches/debian/config/opt/cloud/bin/prepare_pxe.sh
+++ b/systemvm/patches/debian/config/opt/cloud/bin/prepare_pxe.sh
@@@ -1,77 -1,0 +1,77 @@@
 +#!/bin/sh
 +#
 +# 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.
 +#
 +
 +set +u
 +
 +err_exit() {
 +    echo $1
 +    exit 1
 +}
 +
 +success() {
 +    exit 0
 +}
 +
 +TFTP_ROOT='/opt/tftpboot'
 +PXELINUX_CFG_DIR='/opt/tftpboot/pxelinux.cfg'
 +
 +kernel_nfs_path=$1
 +kernel_file_name=`basename $kernel_nfs_path`
 +initrd_nfs_path=$2
 +initrd_file_name=`basename $initrd_nfs_path`
 +tmpt_uuid=$3
 +pxe_cfg_filename=$4
 +ks_file=$5
 +
- kernel_path=$tmpt_uuid/$kernel_file_name
- initrd_path=$tmpt_uuid/$initrd_file_name
- 
- cat > $PXELINUX_CFG_DIR/$pxe_cfg_filename <<EOF
- DEFAULT default
- PROMPT 1
- TIMEOUT 26
- DISPLAY boot.msg
- LABEL default
- KERNEL $kernel_path
- APPEND ramdisk_size=66000 initrd=$initrd_path ks=$ks_file
- 
- EOF
- 
 +tmpt_dir=$TFTP_ROOT/$tmpt_uuid
 +if [ -d $tmpt_dir ]; then
 +    success
 +fi
 +
 +mkdir -p $tmpt_dir
 +
++kernel_path=$tmpt_uuid/$kernel_file_name
++initrd_path=$tmpt_uuid/$initrd_file_name
++
 +mnt_path=/tmp/$(uuid)
 +
 +mkdir -p $mnt_path
 +mount `dirname $kernel_nfs_path` $mnt_path
 +cp -f $mnt_path/$kernel_file_name $tmpt_dir/$kernel_file_name
 +umount $mnt_path
 +
 +mount `dirname $initrd_nfs_path` $mnt_path
 +cp -f $mnt_path/$initrd_file_name $tmpt_dir/$initrd_file_name
 +umount $mnt_path
 +
++cat > $PXELINUX_CFG_DIR/$pxe_cfg_filename <<EOF
++DEFAULT default
++PROMPT 1
++TIMEOUT 26
++DISPLAY boot.msg
++LABEL default
++KERNEL $kernel_path
++APPEND ramdisk_size=66000 initrd=$initrd_path ks=$ks_file
++
++EOF
++
 +success
 +
 +

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/148efbb7/test/integration/component/test_deploy_vgpu_vm.py
----------------------------------------------------------------------
diff --cc test/integration/component/test_deploy_vgpu_vm.py
index 0284eab,b5af092..6cd6c2c
--- a/test/integration/component/test_deploy_vgpu_vm.py
+++ b/test/integration/component/test_deploy_vgpu_vm.py
@@@ -1172,20 -520,308 +1172,296 @@@ class TestvGPUWindowsVm(cloudstackTestC
          cmd.serviceofferingid = self.destvgpuoffering.id
          self.apiclient.changeServiceForVirtualMachine(cmd)
  
 -        self.debug("Starting VM - ID: %s" % vm.id)
 -        self.start_vm()
 +        self.debug("Starting VM - ID: %s" % vmcard.id)
 +        self.start_life_cycle_vm(vmcard)
          time.sleep(self.testdata["vgpu"]["sleep"])
 -
 +        vm=self.check_for_vm(desttype,self.destvgpuoffering.id,vmcard.id)
              # Ensure that VM is in running state
 -        vm=self.check_for_vm(desttype,self.destvgpuoffering.id,vm.id)
 -        self.check_for_vGPU_resource(vm.hostid,vm.instancename,vm.serviceofferingid,vm.vgpu)
 -        self.delete_vgpu_service_offering(self.destvgpuoffering)
 -        self.delete_vgpu_service_offering(self.sourcevgpuoffering)
 -        self.destroy_vm()
 -        return
 +        if destmodel!="None":
 +           self.check_for_vGPU_resource(vm.hostid,vm.instancename,vm.serviceofferingid,vm.vgpu)
  
 -    @attr(tags = ['advanced', 'basic' , 'vgpu'], required_hardware="true")
 -    def deploy_vm(self,type,model):
 +        self.revert_vm_snapshot(vm)
 +
 +        self.delete_vm_snapshot(vm)
  
 -        self.vgpuoffering=self.vgpu_serviceoffering_creation(type,model)
 -        if self.vgpuoffering is not None:
 -              self.deploy_vGPU_windows_vm(self.vgpuoffering.id,type)
 -              time.sleep(self.testdata["vgpu"]["sleep"])
 -              vm=self.check_for_vm(type,self.vgpuoffering.id,self.virtual_machine.id)
 -              self.check_for_vGPU_resource(vm.hostid,vm.instancename,vm.serviceofferingid,vm.vgpu)
 -              self.destroy_vm()
 -              self.delete_vgpu_service_offering(self.vgpuoffering)
 -        return
  
  
+     def new_template_register(self,guestostype):
+ 
+         template1 = get_windows_template(self.apiclient, self.zone.id ,ostype_desc=guestostype)
+ 
+         if  template1 == FAILED:
+             if "http://pleaseupdateURL/dummy.vhd" in cls.testdata["vgpu"] [guestostype]["url"]:
+                 raise unittest.SkipTest("Check Test Data file if it has the valid template
URL")
+             template1 = Template.register(
+                    self.apiclient,
+                    self.testdata["vgpu"] [guestostype],
+                    hypervisor = "XenServer",
+                    zoneid=cls.zone.id,
+                    domainid=cls.account.domainid,
+                    account=cls.account.name
+                    )
+             timeout = self.testdata["vgpu"]["timeout"]
+ 
+             while True:
+                   time.sleep(self.testdata["vgpu"]["sleep"])
+                   list_template_response = Template.list(
+                        self.apiclient,
+                        templatefilter=\
+                        self.testdata["templatefilter"],
+                        id=template1.id
+                         )
+                   if (isinstance(list_template_response, list)) is not True:
+                       raise unittest.SkipTest("Check list template api response returns
a valid list")
+ 
+                   if len(list_template_response) is None :
+                       raise unittest.SkipTest("Check template registered is in List Templates")
+ 
+                   template_response = list_template_response[0]
+                   if template_response.isready == True:
+                       break
+                   if timeout == 0:
+                       raise unittest.SkipTest("Failed to download template(ID: %s)" % template_response.id)
+ 
+                   timeout = timeout - 1
+         return(template1.id)
+ 
+     def deploy_vm_lifecycle(self):
+         """
+         Create Service Offerings for Both K1 and K2 cards to be used for VM life cycle tests
+         """
+ 
+         if(self.k1hosts != 0):
+             if(self.k140qgpuhosts != 0):
+                 gtype = "GRID K140Q"
+             elif(self.k120qgpuhosts != 0):
+                 gtype = "GRID K120Q"
+             elif(self.k100gpuhosts !=0):
+                 gtype = "GRID K100"
+             else:
+                 gtype = "passthrough"
+ 
+             self.testdata["vgpu"]["service_offerings"][gtype]["serviceofferingdetails"]
= [{'pciDevice':'Group of NVIDIA Corporation GK107GL [GRID K1] GPUs'},
+                                                                                        {'vgpuType':gtype}]
+             try:
+                self.__class__.k100_vgpu_service_offering = ServiceOffering.create(
+                                                                     self.apiclient,
+                                                                     self.testdata["vgpu"]["service_offerings"][gtype]
+                                                                     )
+             except Exception as e:
+                self.fail("Failed to create the service offering, %s" % e)
+ 
+         if(self.k2hosts != 0):
+             if(self.k240qgpuhosts != 0):
+                 gtype = "GRID K240Q"
+             elif(cls.k220qgpuhosts != 0):
+                 gtype = "GRID K220Q"
+             elif(self.k200gpuhosts !=0):
+                 gtype = "GRID K200"
+             else:
+                 gtype = "passthrough"
+ 
+             self.testdata["vgpu"]["service_offerings"][gtype]["serviceofferingdetails"]
= [{'pciDevice': 'Group of NVIDIA Corporation GK104GL [GRID K2] GPUs'},
+                                                                                        {'vgpuType':gtype}]
+             try:
+                self.__class__.k200_vgpu_service_offering = ServiceOffering.create(
+                                                                     self.apiclient,
+                                                                     self.testdata["vgpu"]["service_offerings"][gtype]
+                                                                     )
+             except Exception as e:
+               self.fail("Failed to create the service offering, %s" % e)
+ 
+         win8templateid=self.new_template_register("Windows 8 (64-bit)")
+         win2012templateid=self.new_template_register("Windows Server 2012 (64-bit)")
+         win7templateid=self.new_template_register("Windows 7 (64-bit)")
+ 
+         """
+         Create Virtual Machines for Both K1 and K2 cards to be used for VM life cycle tests
+         """
+ 
+         if(self.k1hosts != 0):
+             self.__class__.vm_k1_card = VirtualMachine.create(
+             self.apiclient,
+             self.testdata["virtual_machine"],
+             accountid=self.account.name,
+             zoneid=self.zone.id,
+             domainid=self.account.domainid,
+             serviceofferingid=self.k100_vgpu_service_offering.id,
+             templateid=win8templateid
+             )
+         if(self.k2hosts !=0):
+             self.__class__.vm_k2_card = VirtualMachine.create(
+             self.apiclient,
+             self.testdata["virtual_machine"],
+             accountid=self.account.name,
+             zoneid=self.zone.id,
+             domainid=self.account.domainid,
+             serviceofferingid=self.k200_vgpu_service_offering.id,
+             templateid=win2012templateid
+             )
+         if(self.k2hosts !=0):
+             self.__class__.vm2_k2_card = VirtualMachine.create(
+             self.apiclient,
+             self.testdata["virtual_machine"],
+             accountid=self.account.name,
+             zoneid=self.zone.id,
+             domainid=self.account.domainid,
+             serviceofferingid=self.k200_vgpu_service_offering.id,
+             templateid=win7templateid
+             )
+         return
+ 
+ 
+     def check_gpu_resources_released_vm(self,gpuhostid,vm_vgpu_type,rcapacity):
+         hhosts = list_hosts(
+                self.apiclient,
+                hypervisor="XenServer",
+                id=gpuhostid
+                )
+         self.assertEqual(
+                             isinstance(hhosts, list),
+                             True,
+                             "Check list hosts response returns a valid list"
+                         )
+ 
+         self.assertNotEqual(
+                             len(hhosts),
+                             0,
+                             "Check Host details are available in List Hosts"
+                         )
+         for ggroup in hhosts:
+                if ggroup.ipaddress not in self.nongpuhosts:
+                   for gp in ggroup.gpugroup:
+                       #if gp.gpugroupname == "Group of NVIDIA Corporation GK104GL [GRID
K2] GPUs":
+                          for gptype in gp.vgpu:
+                              if gptype.vgputype==vm_vgpu_type:
+                                 self.debug("Latest remainingcapacity is %s and before remainingcapacity
is %s"%(gptype.remainingcapacity,rcapacity))
+                                 if gptype.remainingcapacity != rcapacity+1:
+                                    self.fail("Host capacity is not updated .GPU resources
should be released when VM is stopped/Destroyed ")
+         return
+ 
+     def check_vm_state(self,vmid):
+         list_vm_response = list_virtual_machines(
+                                                      self.apiclient,
+                                                      id=vmid
+                                                      )
+ 
+         if list_vm_response is None:
+             return("Expunge")
+         return(list_vm_response[0].state)
+ 
+     def check_host_vgpu_remaining_capacity(self,gpuhostid,gtype):
+         gputhosts = list_hosts(
+                self.apiclient,
+                hypervisor="XenServer",
+                id=gpuhostid
+                )
+         vgpucapacity=0
+         for ghost in gputhosts:
+             if ghost.gpugroup is not None:
+                         for gp in ghost.gpugroup:
+                             #if gp.gpugroupname == gpucard:
+                                for gptype in gp.vgpu:
+                                    if gptype.vgputype == gtype:
+                                       vgpucapacity=vgpucapacity+gptype.remainingcapacity
+ 
+         return(vgpucapacity)
+ 
+     def verify_vm(self,vm_gpu_card):
+         if(vm_gpu_card):
+           vm_gpu_card.getState(
+                                    self.apiclient,
+                                    "Running")
+ 
+           self.check_for_vGPU_resource(vm_gpu_card.hostid,vm_gpu_card.instancename,vm_gpu_card.serviceofferingid,vm_gpu_card.vgpu)
+ 
+     def stop_life_cycle_vm (self,vm_gpu_card):
+ 
+         if(vm_gpu_card):
+           vm_gpu_card.stop(self.apiclient)
+           time.sleep(self.testdata["vgpu"]["sleep"])
+           vm_gpu_card.getState(
+                                    self.apiclient,
+                                    "Stopped")
+ 
+     def start_life_cycle_vm(self,vm_gpu_card):
+ 
+         if(vm_gpu_card):
+           vm_gpu_card.start(self.apiclient)
+           time.sleep(self.testdata["vgpu"]["sleep"])
+ 
+     def restore_life_cycle_vm(self,vm_gpu_card):
+         if(vm_gpu_card):
+           vm_gpu_card.restore(self.apiclient)
+           time.sleep(self.testdata["vgpu"]["sleep"])
+ 
+     def reboot_life_cycle_vm(self,vm_gpu_card):
+ 
+         if(vm_gpu_card):
+           vm_gpu_card.reboot(self.apiclient)
+           time.sleep(self.testdata["vgpu"]["sleep"])
+ 
+     def delete_vm_life_cycle_vm(self,vm_gpu_card):
+         if(vm_gpu_card):
+           vm_gpu_card.delete(self.apiclient)
+           time.sleep(self.testdata["vgpu"]["sleep"])
+           vm_gpu_card.getState(
+                                    self.apiclient,
+                                    "Destroyed")
+ 
+     def recover_vm_life_cycle_vm(self,vm_gpu_card):
+         if(vm_gpu_card):
+           vm_gpu_card.recover(self.apiclient)
+           vm_gpu_card.getState(
+                                    self.apiclient,
+                                    "Stopped")
+ 
+ 
+     def recovervm(self,vm_gpu_card):
+         if self.check_vm_state(vm_gpu_card.id)=="Expunge":
+             raise unittest.SkipTest("VM is already deleted hence skipping")
+         self.recover_vm_life_cycle_vm(vm_gpu_card)
+         self.start_life_cycle_vm(vm_gpu_card)
+         self.verify_vm(vm_gpu_card)
+         return
+ 
+ 
+     def startvm(self,vm_gpu_card):
+ 
+         self.start_life_cycle_vm(vm_gpu_card)
+         self.verify_vm(vm_gpu_card)
+         return
+ 
+     def stopvm(self,vm_gpu_card):
+ 
+         rcapacity=self.check_host_vgpu_remaining_capacity(vm_gpu_card.hostid,vm_gpu_card.vgpu)
+         self.stop_life_cycle_vm(vm_gpu_card)
+         self.check_gpu_resources_released_vm(vm_gpu_card.hostid,vm_gpu_card.vgpu,rcapacity)
+         return
+ 
+     def deletevm(self,vm_gpu_card):
+ 
+         rcapacity=self.check_host_vgpu_remaining_capacity(vm_gpu_card.hostid,vm_gpu_card.vgpu)
+         hostid=vm_gpu_card.hostid
+         vgputype=vm_gpu_card.vgpu
+         self.delete_vm_life_cycle_vm(vm_gpu_card)
+         self.check_gpu_resources_released_vm(hostid,vgputype,rcapacity)
+         return
+ 
+     def restorevm(self,vm_gpu_card):
+ 
+         self.restore_life_cycle_vm(vm_gpu_card)
+         self.verify_vm(vm_gpu_card)
+         return
+ 
+ 
+     def rebootvm(self,vm_vgpu_card):
+ 
+         self.reboot_life_cycle_vm(vm_vgpu_card)
+         self.verify_vm(vm_vgpu_card)
+         return
+ 
+ 
      def test_01_list_vgpu_host_details(self):
          """   list vGPU host details  """
          hhosts = list_hosts(
@@@ -1494,17 -1130,10 +1770,15 @@@
  
          self.debug("Check if deployed VMs are in running state?")
  
- 
 -        self.verify_vm(self.__class__.vm_k1_card)
 -        self.verify_vm(self.__class__.vm_k2_card)
 -        self.verify_vm(self.__class__.vm2_k2_card)
 +        if self.__class__.vm_k1_card is not None:
 +            self.verify_vm(self.__class__.vm_k1_card)
 +
 +        if self.__class__.vm_k2_card is not None:
 +            self.verify_vm(self.__class__.vm_k2_card)
 +
 +        if self.__class__.vm2_k2_card is not None:
 +            self.verify_vm(self.__class__.vm2_k2_card)
  
- 
          self.__class__.vmlifecycletest=1
          return
  
@@@ -1515,17 -1144,10 +1789,15 @@@
          if self.__class__.vmlifecycletest==0:
              raise unittest.SkipTest("VM Life Cycle Deploy VM test failed hence skipping")
  
- 
 -        self.stopvm(self.__class__.vm_k1_card)
 -        self.stopvm(self.__class__.vm_k2_card)
 -        self.stopvm(self.__class__.vm2_k2_card)
 +        if self.__class__.vm_k1_card:
 +            self.stopvm(self.__class__.vm_k1_card)
 +
 +        if self.__class__.vm_k2_card:
 +            self.stopvm(self.__class__.vm_k2_card)
 +
 +        if self.__class__.vm2_k2_card:
 +            self.stopvm(self.__class__.vm2_k2_card)
  
- 
          return
  
      @attr(tags = ['advanced', 'basic' , 'vgpu'], required_hardware="true")
@@@ -1535,15 -1157,9 +1807,14 @@@
          if self.__class__.vmlifecycletest==0:
              raise unittest.SkipTest("VM Life Cycle Deploy VM test failed hence skipping")
  
- 
 -        self.startvm(self.__class__.vm_k1_card)
 -        self.startvm(self.__class__.vm_k2_card)
 -        self.startvm(self.__class__.vm2_k2_card)
 +        if self.__class__.vm_k1_card:
 +            self.startvm(self.__class__.vm_k1_card)
 +
 +        if self.__class__.vm_k2_card:
 +            self.startvm(self.__class__.vm_k2_card)
 +
 +        if self.__class__.vm2_k2_card:
 +            self.startvm(self.__class__.vm2_k2_card)
  
          return
  
@@@ -1555,15 -1171,10 +1826,13 @@@
          if self.__class__.vmlifecycletest==0:
              raise unittest.SkipTest("VM Life Cycle Deploy VM test failed hence skipping")
  
- 
 -        self.restorevm(self.__class__.vm_k1_card)
 -        self.restorevm(self.__class__.vm_k2_card)
 -        self.restorevm(self.__class__.vm2_k2_card)
 +        if self.__class__.vm_k1_card:
 +            self.restorevm(self.__class__.vm_k1_card)
 +        if self.__class__.vm_k2_card:
 +            self.restorevm(self.__class__.vm_k2_card)
 +        if self.__class__.vm2_k2_card:
 +            self.restorevm(self.__class__.vm2_k2_card)
  
- 
          return
  
      @attr(tags = ['advanced', 'basic' , 'vgpu'], required_hardware="true")
@@@ -1770,19 -1199,12 +2039,24 @@@
          if self.__class__.vmlifecycletest==0:
              raise unittest.SkipTest("VM Life Cycle Deploy VM test failed hence skipping")
  
 +        if self.__class__.vm_k2_card:
 +            self.deletevm(self.__class__.vm_k2_card)
 +
 +        if self.__class__.vm_k1_card:
 +            self.deletevm(self.__class__.vm_k1_card)
 +
 +        if self.__class__.vm2_k2_card:
 +            self.deletevm(self.__class__.vm2_k2_card)
 +
 +        if self.__class__.nonvgpu:
 +            self.deletevm(self.__class__.nonvgpu)
 +
 +        self.cleanup.append(self.__class__.nonvgpu_service_offerin)
+ 
+         self.deletevm(self.__class__.vm_k1_card)
+         self.deletevm(self.__class__.vm_k2_card)
+         self.deletevm(self.__class__.vm2_k2_card)
+ 
 -
          self.cleanup.append(self.__class__.k100_vgpu_service_offering)
          self.cleanup.append(self.__class__.k200_vgpu_service_offering)
  
@@@ -1959,6 -1373,6 +2233,3 @@@
          except Exception as e:
              self.debug("Warning! Exception in tearDown: %s" % e)
  
--
--
--


Mime
View raw message