当前位置: 首页>>代码示例>>Python>>正文


Python smc_firewall.cmd函数代码示例

本文整理汇总了Python中smc_firewall.cmd函数的典型用法代码示例。如果您正苦于以下问题:Python cmd函数的具体用法?Python cmd怎么用?Python cmd使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了cmd函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: create_data_snapshot

    def create_data_snapshot(self, node, prefix, zone='us-central1-c', devel=False):
        """
        Snapshot the data disk on the given machine.  Typically used for
        backing up very important data.
        """
        zone = self.expand_zone(zone)
        instance_name = self.instance_name(node, prefix, zone, devel=devel)
        info = json.loads(cmd(['gcloud', 'compute', 'instances', 'describe',
                               instance_name, '--zone', zone, '--format=json'], verbose=0))

        errors = []
        for disk in info['disks']:
            if disk.get('boot', False):
                continue
            src = disk['deviceName']
            if 'swap' in src: continue
            target = 'data-%s-%s'%(src, time.strftime(TIMESTAMP_FORMAT))
            log("%s --> %s", src, target)
            try:
                cmd(['gcloud', 'compute', 'disks', 'snapshot',
                     '--project', self.project,
                    src,
                     '--snapshot-names', target,
                     '--zone', zone], system=True)
            except Exception, mesg:
                log("WARNING: issue making snapshot %s -- %s", target, mesg)
                errors.append(mesg)
开发者ID:nikolas,项目名称:smc,代码行数:27,代码来源:gce.py

示例2: create_data_snapshot

    def create_data_snapshot(self, node, prefix, zone='us-central1-c', devel=False):
        """
        Snapshot the data disk on the given machine.  Typically used for
        backing up very important data.
        """
        zone = self.expand_zone(zone)
        instance_name = self.instance_name(node, prefix, zone, devel=devel)
        info = json.loads(cmd(['gcloud', 'compute', 'instances', 'describe',
                               instance_name, '--zone', zone, '--format=json'], verbose=0))

        errors = []
        for disk in info['disks']:
            # ignore boot disks (would be True)
            if disk.get('boot', False):
                continue
            # ignore read-only disks (like for globally mounted data volumes)
            # they would be snapshotted manually
            if disk.get('mode', 'READ_WRITE') == 'READ_ONLY':
                continue

            src = disk['source'].split('/')[-1]
            if 'swap' in src: continue
            if 'tmp' in src: continue
            target = 'data-%s-%s'%(src, time.strftime(TIMESTAMP_FORMAT))
            log("%s --> %s", src, target)
            try:
                cmd(['gcloud', 'compute', 'disks', 'snapshot',
                     '--project', self.project,
                    src,
                     '--snapshot-names', target,
                     '--zone', zone], system=True)
            except Exception, mesg:
                log("WARNING: issue making snapshot %s -- %s", target, mesg)
                errors.append(mesg)
开发者ID:angelapper,项目名称:smc,代码行数:34,代码来源:gce.py

示例3: start_cassandra

def start_cassandra():
    log("start_cassandra...")
    services = admin.Services('conf/deploy_devel/', password='')
    services.start('cassandra')
    cmd("ln -sf %s/data/cassandra-0/logs/system.log %s/logs/cassandra.log"%(SALVUS_ROOT, os.environ['HOME']))
    log("cassandra started")
    log("waiting 30 seconds...")
    import time; time.sleep(30)
开发者ID:nikolas,项目名称:smc,代码行数:8,代码来源:dev_init.py

示例4: setup_quota

def setup_quota():
    log("quota packages")
    cmd("sudo apt-get install -y libatlas3gf-base liblapack-dev  quota quotatool linux-image-extra-virtual cgroup-lite cgmanager-utils cgroup-bin libpam-cgroup cgmanager cgmanager-utils  cgroup-bin smem", system=True)
    log("quota stuff")
    cmd("echo 'LABEL=cloudimg-rootfs /        ext4   defaults,usrquota       0 0' | sudo tee /etc/fstab")
    cmd("sudo mount -o remount /")
    log("initializing quota, which will take a while")
    cmd("sudo quotacheck -fucm /")
    cmd("sudo quotaon /")
开发者ID:nikolas,项目名称:smc,代码行数:9,代码来源:dev_init.py

示例5: delete_devel_instances

 def delete_devel_instances(self):
     for x in cmd(['gcloud', 'compute', 'instances', 'list'], verbose=0).splitlines()[1:]:
         v = x.split()
         name         = v[0]
         if '-devel-' in name:
             zone         = v[1]
             status       = v[-1]
             log("deleting devel instance: %s"%name)
             cmd(['gcloud', 'compute', 'instances', 'delete', '--zone', zone, name], system=True)
开发者ID:angelapper,项目名称:smc,代码行数:9,代码来源:gce.py

示例6: start_devel_instances

 def start_devel_instances(self):
     for x in cmd(['gcloud', 'compute', 'instances', 'list']).splitlines()[1:]:
         v = x.split()
         name         = v[0]
         if '-devel-' in name:
             zone         = v[1]
             status       = v[-1]
             if status == "TERMINATED":
                 log("starting %s"%name)
                 cmd(['gcloud', 'compute', 'instances', 'start', '--zone', zone, name])
开发者ID:angelapper,项目名称:smc,代码行数:10,代码来源:gce.py

示例7: create_boot_snapshot

 def create_boot_snapshot(self, node, prefix, zone='us-central1-c', devel=False):
     """
     Snapshot the boot disk on the give machine.  Typically used for
     replicating configuration.
     """
     zone = self.expand_zone(zone)
     instance_name = self.instance_name(node, prefix, zone, devel=devel)
     snapshot_name = "%s%s-%s"%(prefix, node, time.strftime(TIMESTAMP_FORMAT))
     cmd(['gcloud', 'compute', 'disks', 'snapshot', '--project', self.project,
         instance_name,
         '--snapshot-names', snapshot_name,
         '--zone', zone], system=True)
开发者ID:angelapper,项目名称:smc,代码行数:12,代码来源:gce.py

示例8: create_dev

    def create_dev(self, node, zone='us-central1-c', machine_type='n1-standard-1', size=30, preemptible=True, address=''):
        zone = self.expand_zone(zone)
        name = self.instance_name(node=node, prefix='dev', zone=zone)

        log("creating %sGB hard disk root filesystem image based on last smc snapshot", size)
        try:
            cmd(['gcloud', 'compute', '--project', self.project, 'disks', 'create', name,
                 '--zone', zone, '--source-snapshot', self.newest_snapshot('smc'),
                 '--size', size, '--type', 'pd-standard'])
        except Exception, mesg:
            if 'already exists' not in str(mesg):
                raise
开发者ID:angelapper,项目名称:smc,代码行数:12,代码来源:gce.py

示例9: autostart

 def autostart(self, instance):
     """
     Ensure that each instance in the input is running.
     """
     for x in cmd(['gcloud', 'compute', 'instances', 'list'], verbose=0).splitlines()[1:]:
         v = x.split()
         if len(v) > 2 and v[-1] != 'RUNNING':
             name = v[0]; zone = v[1]
             for x in instance:
                 if name.startswith(x):
                     log("Starting %s... at %s", name, time.asctime())
                     cmd(' '.join(['gcloud', 'compute', 'instances', 'start', '--zone', zone, name]) + '&', system=True)
                     break
开发者ID:angelapper,项目名称:smc,代码行数:13,代码来源:gce.py

示例10: _create_storage_server

    def _create_storage_server(self, node, zone, machine_type,
                               disk_size, network, devel):
        zone = self.expand_zone(zone)
        name = self.instance_name(node=node, prefix='storage', zone=zone, devel=devel)
        disk_name = "%s-projects"%name

        log("creating hard disk root filesystem image")
        try:
            cmd(['gcloud', 'compute', '--project', self.project, 'disks', 'create', name,
                 '--zone', zone, '--source-snapshot', self.newest_snapshot('storage'),
                 '--type', 'pd-standard'])
        except Exception, mesg:
            if 'already exists' not in str(mesg):
                raise
开发者ID:angelapper,项目名称:smc,代码行数:14,代码来源:gce.py

示例11: devel_etc_hosts

 def devel_etc_hosts(self):
     hosts = []
     for x in cmd(['gcloud', 'compute', 'instances', 'list'], verbose=0).splitlines()[1:]:
         v = x.split()
         name         = v[0]
         if '-devel-' in name:
             i = name.find('-devel')
             hosts.append("%s %s %s"%(v[4], v[0], v[0][:i+6]))
     if hosts:
         print "\n".join(hosts)
         x = open("/etc/hosts").readlines()
         y = [a.strip() for a in x if '-devel-' not in a]
         open('/tmp/hosts','w').write('\n'.join(y+hosts))
         cmd("sudo cp -v /etc/hosts /etc/hosts.0 && sudo cp -v /tmp/hosts /etc/hosts", system=True)
开发者ID:angelapper,项目名称:smc,代码行数:14,代码来源:gce.py

示例12: _create_smc_server

    def _create_smc_server(self, node, zone='us-central1-c', machine_type='n1-highmem-2',
                          disk_size=100, network='default', devel=False):
        zone = self.expand_zone(zone)
        name = self.instance_name(node=node, prefix='smc', zone=zone, devel=devel)
        disk_name = "%s-cassandra"%name

        log("creating hard disk root filesystem image")
        try:
            cmd(['gcloud', 'compute', '--project', self.project, 'disks', 'create', name,
                 '--zone', zone, '--source-snapshot', self.newest_snapshot('smc'),
                 '--type', 'pd-standard'])
        except Exception, mesg:
            if 'already exists' not in str(mesg):
                raise
开发者ID:angelapper,项目名称:smc,代码行数:14,代码来源:gce.py

示例13: set_metadata

 def set_metadata(self, prefix=''):
     if not prefix:
         for p in ['smc', 'compute', 'admin', 'storage']:
             self.set_metadata(p)
         return
     names = []
     for x in cmd(['gcloud', 'compute', 'instances', 'list']).splitlines()[1:]:
         v = x.split()
         if v[-1] != 'RUNNING':
             continue
         name = v[0]
         if name.startswith(prefix) and 'devel' not in name: #TODO
             names.append(name)
     names = ' '.join(names)
     cmd(['gcloud', 'compute', 'project-info', 'add-metadata', '--metadata', '%s-servers=%s'%(prefix, names)])
开发者ID:vishnuvr,项目名称:smc,代码行数:15,代码来源:gce.py

示例14: dev_instances

 def dev_instances(self):
     a = []
     for x in cmd(['gcloud', 'compute', 'instances', 'list']).splitlines()[1:]:
         name = x.split()[0]
         if name.startswith('dev'):
             a.append(name)
     return a
开发者ID:angelapper,项目名称:smc,代码行数:7,代码来源:gce.py

示例15: compute_nodes

 def compute_nodes(self, zone='us-central1-c'):
     # names of the compute nodes in the given zone, with the zone postfix and compue prefix removed.
     n = len("compute")
     def f(name):
         return name[n:name.rfind('-')]
     info = json.loads(cmd(['gcloud', 'compute', 'instances', 'list', '-r', '^compute.*', '--format=json'], verbose=0))
     return [f(x['name']) for x in info if x['zone'] == zone and f(x['name'])]
开发者ID:angelapper,项目名称:smc,代码行数:7,代码来源:gce.py


注:本文中的smc_firewall.cmd函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。